一、下载rpm安装包
地址 https://dev.mysql.com/downloads/mysql/
二、卸载自带mariaDB
使用命令:yum remove mysql-libs yum
remove mysql-libs
三、安装rpm包
[jk@bogon mysql]$ sudo rpm -ivh mysql-community-libs-8.0.15-1.el7.x86_64.rpm
警告:mysql-community-libs-8.0.15-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-libs-8.0.15-1.el7################################# [100%]
[jk@bogon mysql]$ sudo rpm -ivh mysql-community-libs-compat-8.0.15-1.el7.x86_64.rpm
警告:mysql-community-libs-compat-8.0.15-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-libs-compat-8.0.1################################# [100%]
警告:mysql-community-devel-8.0.15-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-devel-8.0.15-1.el################################# [100%]
[jk@bogon mysql]$ sudo rpm -ivh mysql-community-embedded-compat-8.0.15-1.el7.x86_64.rpm
警告:mysql-community-embedded-compat-8.0.15-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-embedded-compat-8################################# [100%]
[jk@bogon mysql]$ sudo rpm -ivh mysql-community-client-8.0.15-1.el7.x86_64.rpm
警告:mysql-community-client-8.0.15-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-client-8.0.15-1.e################################# [100%]
[jk@bogon mysql]$ sudo rpm -ivh mysql-community-server-8.0.15-1.el7.x86_64.rpm
警告:mysql-community-server-8.0.15-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-server-8.0.15-1.e################################# [100%]
[jk@bogon mysql]$ sudo rpm -ivh mysql-community-test-8.0.15-1.el7.x86_64.rpm
警告:mysql-community-test-8.0.15-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
错误:依赖检测失败:
perl(Data::Dumper) 被 mysql-community-test-8.0.15-1.el7.x86_64 需要
perl(JSON) 被 mysql-community-test-8.0.15-1.el7.x86_64 需要
[jk@bogon mysql]$ yum -y install perl
perl,下载地址如下:
https://www.activestate.com/products/activeperl/downloads/
四、屏蔽登陆权限校验
[root@bogon mysql]# vim /etc/my.cnf
skip-grant-tables #添加这句话,这时候登入mysql就不需要密码
symbolic-links=0
[root@bogon mysql]#
五、更改root密码
8以下版本可以通过如下命令:
mysql> SET PASSWORD = PASSWORD('123456');
//或者
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');
8以上版本用下吗的命令:
mysql> alter user 'root'@'localhost' IDENTIFIED BY '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> alter user 'root'@'localhost' IDENTIFIED BY '*******';
Query OK, 0 rows affected (0.30 sec)
六、恢复登陆权限校验
注释 /etc/my.cnf 里面的内容
七、增加用户
create user 'jk'@'%'IDENTIFIED BY 'jikong93';
八、打开远程连接端口
GRANT ALLON *.* TO 'jk'@'%' ;
Flush privileges;
九、客户端连接数据库
下载最新版jdbc驱动
地址: https://dev.mysql.com/downloads/connector/j/