目录
一、配置yum源
1.下载mysql源安装包执行下载命令:
wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
2.安装mysql源
下载完成后使用下面命令安装源:
yum localinstall mysql80-community-release-el7-1.noarch.rpm
3.检查是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
![](https://img2020.cnblogs.com/blog/1950072/202006/1950072-20200601201443119-744608277.png)
4.修改安装版本(非必须)
修改/etc/yum.repos.d/mysql-community.repo源
![](https://img2020.cnblogs.com/blog/1950072/202006/1950072-20200601201451074-12920719.png)
要安装的版本, 设置enabled=1即可,其他enabled=0
二、安装mysql
直接使用命令:yum install mysql-community-server
即可。
三、启动mysql服务
1.启动
systemctl start mysqld
或者
service mysqld start
2.查看启动状态
systemctl status mysqld
或者
service mysqld status
3.设置开机启动
systemctl enable mysqld
systemctl daemon-reload
四、配置mysql
1.修改登录密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
grep 'temporary password' /var/log/mysqld.log
本地MySQL客户端登录
mysql -uroot -p
密码是刚才查询出来的,输入后回车。
然后修改密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
或者
set password for 'root'@'localhost'=password('root');
修改临时密码,因密码过于简单,不符合MySQL密码规范,会触发一个报错信息:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
![](https://img2020.cnblogs.com/blog/1950072/202006/1950072-20200601201554272-1226286456.png)
解决参考:
https://www.cnblogs.com/zgxblog/p/10708182.html
![](https://img2020.cnblogs.com/blog/1950072/202006/1950072-20200601201733406-99124583.png)
参考:
https://blog.csdn.net/danykk/article/details/80137223
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root@123456';
最后没改成简单密码,还是设置了复杂密码......
最终密码