一、使用yum安装mysql服务
官方:下载对应的yum源
1、yum源下载
[root@localhost ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
[root@localhost ~]# rpm -ivh mysql80-community-release-el7-7.noarch.rpm
如下图所示:
说明:默认是开启mysql80-community/x86_64的yum源,如果要安装mysql57版本,则如下所示:
[root@localhost ~]# yum -y install yum-utils
[root@localhost ~]# yum-config-manager --disable mysql80-community
[root@localhost ~]# yum-config-manager --enable mysql57-community
2、yum安装mysql
[root@localhost ~]# yum install mysql-community-server -y
3、启动mysql服务
[root@localhost ~]# systemctl start mysqld.service
4、启动mysql服务
[root@localhost ~]# systemctl enable mysqld.service
二、修改root用户临时密码
1、查看root用户初始密码并登录
[root@localhost ~]# grep "temporary password" /var/log/mysqld.log
如下图所示:
2、修改root用户初始密码
mysql> ALTER USER USER() IDENTIFIED BY 'Lolaage@sdjw2022';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Lolaage@sdjw2022';
Query OK, 0 rows affected (0.00 sec)
如下图所示:
三、修改root用户远程登录权限
[root@localhost pkgs]# mysql -uroot -pLolaage@sdjw2022
mysql> select user,host from mysql.user;
mysql> use mysql
mysql> update user set host = '%' where user = 'root';
如下图所示:
总结:整理不易,如果对你有帮助,可否点赞关注一下?
更多详细内容请参考:《Linux运维篇:Linux系统运维指南》