cenos7安装mysql5.7服务
1.下载并安装MySQL官方的 Yum Repository
[root@localhost ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
[root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm
[root@localhost ~]# yum -y install mysql-community-server
2.启动和重设密码
# 启动服务
[root@localhost ~]# systemctl start mysqld.service
# 查看服务状态
[root@localhost ~]# systemctl status mysqld.service
# 查看默认随机密码
[root@localhost ~]# grep "password" /var/log/mysqld.log
# 登录数据库
# 注意:重设密码时,默认密码规则(要求密码至少包含一个大写字母,一个小写字母,一位数字和一个特殊字符,并且密码总长度至少为8个字符)
[root@localhost ~]# mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
# mysql默认只能本机登录,通过以下命令,设置允许远程登录:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'your username'@'%' IDENTIFIED BY 'new password' WITH GRANT OPTION;
参考博客地址: