CentOS8安装MySQL5.7
不想使用MySQL8,只想使用MySQL5.7,可以按照以下方法安装。
禁用默认的MySQL源
sudo dnf remove @mysql
sudo dnf module reset mysql
sudo dnf module disable mysql
创建MySQL5.7的源文件
sudo vi /etc/yum.repos.d/mysql-community.repo
文件内容如下:
[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
禁用MySQL8安装源
sudo dnf config-manager --disable mysql80-community
启用MySQL5.7安装源
sudo dnf config-manager --enable mysql57-community
安装MySQL5.7
sudo dnf install mysql-community-server
查看MySQL安装版本信息
rpm -qi mysql-community-server
设置开机启动MySQL
sudo systemctl enable --now mysqld.service
获得当前MySQL临时登录密码
sudo grep 'A temporary password' /var/log/mysqld.log |tail -1
执行安全安装并且修改MySQL密码
sudo mysql_secure_installation
用新密码登录到MySQL
mysql -u root -p