通过软件源安装MySQL数据库
官网地址:https://dev.mysql.com/downloads/repo/yum/
1,通过wget命令下载MySQL的RPM包(默认式最新版)
[root@localhost ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
2,安装到本地,并更新系统和软件配置文件
[root@localhost ~]# yum -y localinstall mysql80-community-release-el7-5.noarch.rpm #从本机目录安装软件包
[root@localhost ~]# yum -y update #系统和软件配置文件更新
[root@localhost ~]# yum -y install mysql-server mysql #安装MySQL和MySQL服务器
3,安全初始化,并查看临时密码(用于首次登录)
[root@localhost tmp]# mysqld --initialize --user=mysql
[root@localhost tmp]# cat /var/log/mysqld.log
4,重起MySQL服务,并登录MySQL,修改永久性密码
[root@localhost tmp]# systemctl restart mysqld
mysql> alter user 'root'@'localhost' identified by '1';