1、多年前写了一篇文章:
centos7安装和卸载mysql5.7.18完整实用教程
https://blog.csdn.net/libaineu2004/article/details/76212125
https://downloads.mysql.com/archives/community/
2、今天安装新版本mysql 8.0.28。整个过程与5.x有不同。
(1)8.x需要7个软件安装包,如下顺序依次安装
[root@localhost mysql]# rpm -ivh mysql-community-common-8.0.28-1.el7.x86_64.rpm
[root@localhost mysql]# rpm -ivh mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm
[root@localhost mysql]# rpm -ivh mysql-community-libs-8.0.28-1.el7.x86_64.rpm
[root@localhost mysql]# rpm -ivh mysql-community-client-8.0.28-1.el7.x86_64.rpm
[root@localhost mysql]# rpm -ivh mysql-community-icu-data-files-8.0.28-1.el7.x86_64.rpm
[root@localhost mysql]# rpm -ivh mysql-community-server-8.0.28-1.el7.x86_64.rpm
[root@localhost mysql]# rpm -ivh mysql-community-devel-8.0.28-1.el7.x86_64.rpm
(2)修改root密码
放弃旧方法
mysql> set password for root@localhost = password('Mypwd123456$');
使用新方法
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Mypwd123456$';
(3)为 root 用户授权 mysql 远程连接服务
放弃旧方法
mysql> grant all privileges on *.* to 'root'@'%' identified by 'Mypwd123456$' with grant option;
mysql> flush privileges;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'Mypwd123456$' with grant option' at line 1
使用新方法
mysql> create user 'root'@'%' identified by 'Mypwd123456$';
mysql> grant all privileges on *.* to 'root'@'%';
- mysql> use mysql
- Database changed
- mysql> select user,host from user;
- +------------------+-----------+
- | user | host |
- +------------------+-----------+
- | mysql.infoschema | localhost |
- | mysql.session | localhost |
- | mysql.sys | localhost |
- | root | localhost |
- +------------------+-----------+
- 4 rows in set (0.00 sec)
-
- mysql> create user 'root'@'%' identified by 'Mypwd123456$';
- Query OK, 0 rows affected (0.01 sec)
-
- mysql> grant all privileges on *.* to 'root'@'%';
- Query OK, 0 rows affected (0.00 sec)
-
- mysql> exit