下载并安装MySQL官方的 Yum Repository
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm yum -y install mysql57-community-release-el7-10.noarch.rpm yum -y install mysql-community-server
启动服务,获取默认密码
systemctl start mysqld.service systemctl status mysqld.service grep "password" /var/log/mysqld.log
登录mysql,修改密码
mysql -uroot -p
修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
会提示密码不符合安全要求,修改安全要求(实际环境别这么干)
set global validate_password_policy=0; set global validate_password_length=6;
修改密码并配置非本机访问
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;