mysql 8.0 远程_MySql8.0安装以后不能远程访问

MySql8.0安装以后不能远程访问

正常安装完8.0是允许远程访问的,如果不能正常访问,可能有两个原因:

原因1:mysql database中的user表中,没有host = %,user=root的记录。

原因2:访问的加密方式不对,旧版的MySql和新版的密码加密方式不一致。但是很多企业和个人都习惯使用旧版的加密方式。

1. 原因1的解决方式

mysql -u root -p

###输入密码,进入mysql###

#使用 mysql库

mysql> use mysql;

#查询使用情况

mysql> select host, user, plugin from user;

+-----------+------------------+-----------------------+

| host | user | plugin |

+-----------+------------------+-----------------------+

| % | root | mysql_native_password |

| localhost | mysql.infoschema | caching_sha2_password |

| localhost | mysql.session | caching_sha2_password |

| localhost | mysql.sys | caching_sha2_password |

| localhost | root | mysql_native_password |

+-----------+------------------+-----------------------+

5 rows in set (0.00 sec)

##如果有 % | root 表示可以远程方法,如果没有

##更改root用户,可以远程访问

mysql> update user set host='%' where user='root';

2. 原因2的解决方式

mysql -u root -p

###输入密码,进入mysql###

#使用 mysql库

mysql> use mysql;

#查询使用情况

mysql> select host, user, plugin from user;

+-----------+------------------+-----------------------+

| host | user | plugin |

+-----------+------------------+-----------------------+

| % | root | caching_sha2_password |

| localhost | mysql.infoschema | caching_sha2_password |

| localhost | mysql.session | caching_sha2_password |

| localhost | mysql.sys | caching_sha2_password |

| localhost | root | caching_sha2_password |

+-----------+------------------+-----------------------+

5 rows in set (0.00 sec)

##如果plugin 的加密方式为caching_sha2_password,表示需要更改

##更改root用户加密方式

mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'root123';

mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root123';

#修改完成后,查询是否正确

mysql> select host, user, plugin from user;

#如果修改正确,刷新权限

mysql> FLUSH PRIVILEGES;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值