详细原文:https://blog.csdn.net/wohiusdashi/article/details/89358071
1、由于CentOS 的yum源中没有mysql,需要到mysql的官网下载yum repo配置文件。
下载命令:
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm·
2、然后进行repo的安装:
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
3.必须进入到 /etc/yum.repos.d/目录后再执行以下脚本
yum install mysql-server
4.启动mysql
systemctl start mysqld #启动MySQL
5.获取初始化密码
grep 'temporary password' /var/log/mysqld.log
ps:执行时报错
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
删除掉
rm -rf /var/lib/mysql
6.修改密码为123456
更改密码长度和强度,修改密码
set global validate_password_policy=LOW;
set global validate_password_length=6;
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';