1、安装wget
yum install wget
2、mysql下载
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
3、安装软件源
rpm -Uvh mysql57-community-release-el7-10.noarch.rpm
4、 安装mysql服务端
yum install -y mysql-community-server
5、启动mysql
service mysqld start
如果在启动服务时失败,报如下错误
Job for mysqld.service failed because the control process exited with error code. See “systemctl status mysqld.service” and “journalctl -xe” for details.**
参见另一篇文章
虚拟机启动mysql服务遇到的问题
6、检查mysql运行状态
service mysqld status
7、查看临时密码
grep 'temporary password' /var/log/mysqld.log
8、输入临时密码,进行登录
mysql -u root -p
9、修改validate_password_policy参数的值
set global validate_password_policy=0;
10、修改密码的长度
set global validate_password_length=1;
11、修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
如果不执行9和10,直接修改密码,会报如下错误
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
以上就是虚拟机操作mysql的基本步骤,下面附上参考文章链接