centos 7 安装 mysql 5.7

使用 yum 进行安装
添加 mysql yum 源

shell> cd /tmp && wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
# 本地安装源
shell> yum localinstall -y mysql80-community-release-el7-3.noarch.rpm 
# 查看源启动情况
shell> yum repolist all | grep mysql
centos 7 安装 mysql 5.7_第1张图片
image.png

切换到 5.7

# 禁用 mysql 8.0
shell> sudo yum-config-manager --disable mysql80-community
# 启用 mysql 5.7
shell> sudo yum-config-manager --enable mysql57-community
# 安装 mysql 5.7
shell> sudo yum install -y mysql-community-server

设置开机启动并启动服务

shell> systemctl enable mysqld
shell> systemctl start mysqld
shell> systemctl status mysqld

查看默认密码

shell> sudo grep 'temporary password' /var/log/mysqld.log

修改 root 密码

shell> mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

你可能感兴趣的:(centos 7 安装 mysql 5.7)