linux 安装mysql8 设置远程连接失败的问题

时间:2021-07-24 03:14:11

1、数据库安装完,设置远程连接 ,参考链接:https://blog.csdn.net/yunyexiangfeng/article/details/82876964

通常grant all privileges on *.* to ‘user‘@‘%‘ identified by ‘passowr‘;命令授权远程连接操作。(失败)

mysql的官方文档,原来这个特性被移除了,下面看文档说明:

Using GRANT to modify account properties other than privilege assignments. This includes
authentication, SSL, and resource-limit properties. Instead, establish such properties at account-creation
time with CREATE USER or modify them afterward with ALTER USER
使用grant修改账户权限分配以外的账户属性。包括认证,SSL,和资源限制配置等。取而代之的是创建用户create user或者创建后修改alter user的方式。

可以使用以下方式:

1.alter user set user.host=‘%‘ where user.user=‘root‘,此时印证官方doc说的使用alter user

2.create user ‘userName‘@‘%‘ identified ...,创建新用户,此时使用create user

工具登录数据库问题:

mysql8密码加密方式的更改:

之前默认是mysql_native_password,现在改为caching_sha2_password。很多连接工具,像nivacat12,仍然使用默认的mysql_native_password,所以在连接的时候回报错:

1251:Client does not support authentication protocol requested by server; consider upgrading
MySQL client

此时需要将mysql.user表中的plugin字段修改下:

ALTER USER user IDENTIFIED WITH mysql_native_password BY ‘password‘;