部署mysql

mysql官方地址:

https://dev.mysql.com/downloads/mysql/

 

一. 部署数据库mysql5.6
cd /opt
wget https://cdn.mysql.com/archives/mysql-5.6/MySQL-5.6.49-1.el7.x86_64.rpm-bundle.tar
mkdir mysql5.6
tar -xf MySQL-5.6.49-1.el7.x86_64.rpm-bundle.tar -C mysql5.6
cd mysql5.6
yum localinstall ./*


1.安装完成后,检查mysql配置文件,修改一下(不修改启动报错)
cat /etc/my.cnf

 # 修改 mysqld_safe里面的内容,原本是mariadb,换成mysql


[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mysql/mysql.log
pid-file=/var/run/mysql/mysql.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

  


1)mysql安装后会出现一个默认随机密码
cat ~/.mysql_secret
# The random password set for the root user at Thu Jan 9 05:33:17 2025 (local time): ozYc0qv5OFIBzcP3


2.启动mysql
systemctl start mysql
systemctl enable mysql

 

3.修改root密码

方法一:(必须执行这一步,以后修改密码可用方法二)
mysqladmin -uroot -pozYc0qv5OFIBzcP3 password 123456

方法二:(进入mysql修改)

# 进入mysql
mysql -uroot -p

#修改密码
update mysql.user set password=password('123456') where user='root';

# 刷新生效
flush privileges;

  

  

 

posted @ 2025-01-09 21:42  铿锵有力自信且坚定  阅读(34)  评论(0)    收藏  举报