安装虚拟机
https://blog.csdn.net/qq_35206244/article/details/79339453
界面如下:
安装mysql
使用yum安装
参考
https://blog.csdn.net/qq_41510551/article/details/110731610
有一个值得注意的点,我第一次安装的时候 就自己给挖坑了
如果自己下了一个mysql80或者50的 就不需要切换版本,命令:disable/enable
如果已经用了7条命令可以使用如下方法解决:
[root@localhost /]# rpm -qa | grep -i mysql
mysql80-community-release-el7-3.noarch
[root@localhost /]# yum remove mysql80-community-release-el7-3.noarch
已加载插件:fastestmirror, langpacks
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql80-community-release.noarch.0.el7-3 将被 删除
--> 解决依赖关系完成
依赖关系解决
=================================================================================================================================================================================================================================================
Package 架构 版本 源 大小
=================================================================================================================================================================================================================================================
正在删除:
mysql80-community-release noarch el7-3 installed 31 k
事务概要
=================================================================================================================================================================================================================================================
移除 1 软件包
安装大小:31 k
是否继续?[y/N]:y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
正在删除 : mysql80-community-release-el7-3.noarch 1/1
警告:文件 /etc/yum.repos.d/mysql-community.repo: 移除失败: 没有那个文件或目录
警告:文件 /etc/yum.repos.d/mysql-community-source.repo: 移除失败: 没有那个文件或目录
验证中 : mysql80-community-release-el7-3.noarch 1/1
删除:
mysql80-community-release.noarch 0:el7-3
完毕!
完毕!
[root@localhost /]# rpm -qa | grep -i mysql
[root@localhost /]# ll
总用量 32
lrwxrwxrwx. 1 root root 7 8月 7 2021 bin -> usr/bin
dr-xr-xr-x. 5 root root 4096 8月 7 2021 boot
drwxr-xr-x. 20 root root 3340 8月 7 13:17 dev
drwxr-xr-x. 145 root root 12288 8月 7 13:19 etc
drwxr-xr-x. 3 root root 17 8月 7 2021 home
lrwxrwxrwx. 1 root root 7 8月 7 2021 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 8月 7 2021 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 31 8月 7 2021 liuqing
drwxr-xr-x. 2 root root 6 4月 11 2018 media
drwxr-xr-x. 2 root root 6 4月 11 2018 mnt
drwxr-xr-x. 3 root root 16 8月 7 13:16 opt
dr-xr-xr-x. 232 root root 0 8月 7 13:17 proc
dr-xr-x---. 14 root root 4096 8月 7 13:19 root
drwxr-xr-x. 44 root root 1280 8月 7 13:34 run
lrwxrwxrwx. 1 root root 8 8月 7 2021 sbin -> usr/sbin
drwxr-xr-x. 2 root root 6 4月 11 2018 srv
dr-xr-xr-x. 13 root root 0 8月 7 13:17 sys
drwxrwxrwt. 23 root root 4096 8月 7 13:34 tmp
drwxr-xr-x. 13 root root 155 8月 7 2021 usr
drwxr-xr-x. 21 root root 4096 8月 7 2021 var
再按照连接执行就可以啦
用Navicat连接
常规和SSL配置:
连接名:
主机名或AP地址:192.168.** ./localhost
用户名:root
密码****
连接测试*
报错1:
解决办法:
使用命令修改%为通配符,可以允许主机ip192.168.172.7**访问,如果最后不是1开始就不用执行这步操作
use mysql;
select host from user where user='root';
报错2:
修改的原因是因为MySQL8使用了新的认证插件,也就是上面错误中提到的“caching_sha2_password”,一些低版本的Navicat还不支持这个新的插件,所以才会出现错误。navicat12.0.28已经支持新的验证方式。
解决办法:
mysql> select host,user,plugin,authentication_string from mysql.user;
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| host | user | plugin | authentication_string |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| % | root | caching_sha2_password | $A$005$byr {OmJ`rBf%!Q0KeqZ3a/W8Wn0/38ZDGvLbSWYDXqrlokYnxiCaOmX3 |
| localhost | mysql.infoschema | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.session | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.sys | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.01 sec)
mysql> select host,user,plugin,authentication_string from mysql.user;
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| host | user | plugin | authentication_string |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| localhost | mysql.infoschema | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.session | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.sys | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | root | mysql_native_password | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
4 rows in set (0.00 sec)
连接成功。