CentOS 8 里安装 mysql 5.7

CentOS 8里,默认是安装MariaDB,Oracle仅提供MySQL 8的yum源。如需安装MySQL 5.7,可手动创建yum源配置文件,内容与CentOS 7的一样。

1.dnf module disable mysql # 禁用默认的mysql安装源

2.vi /etc/yum.repos.d/mysql-community.repo # 创建yum安装源文件,内容如下:

[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0

[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/7/$basearch/
enabled=1
gpgcheck=0

[mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/7/$basearch/
enabled=1
gpgcheck=0

3.dnf --enablerepo=mysql57-community install mysql-community-server # 安装 mysql 5.7

4.systemctl enable --now mysqld.service # 启动 mysql

5.grep 'A temporary password' /var/log/mysqld.log |tail -1 # 查看自动生成的mysql的root账户密码

6.mysql_secure_installation # 初始化mysql的安全设置

参考:https://unix.stackexchange.com/questions/555285/installing-mysql-5-7-on-centos-8

标签: mysql

添加新评论