下载mysql5.7源安装包
[root@localhost ~]# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
安装mysql5.7源
[root@localhost ~]# yum localinstall mysql57-community-release-el7-8.noarch.rpm
安装mysql5.7
[root@localhost ~]# yum install mysql-community-server
启动mysql,并将其加入到自启动。
[root@localhost ~]# systemctl start mysqld
[root@localhost ~]# systemctl enable mysqld
mysql5.7之后,安装完会在日志文件中记录一个临时密码
[root@localhost ~]# grep 'password' /var/log/mysqld.log
2021-01-15T04:16:30.625890Z 1 [Note] A temporary password is generated for root@localhost: 7ekCWLjPda-D
用刚查出来的密码登录mysql
[root@localhost ~]# mysql -u root -p
初次登录,root无权限,需要改密之后才可以正常使用mysql
mysql> alter user 'root'@'localhost' identified by 'MyNewPassword123!';
网友评论