MySQL不能被其他地址访问,授权问题解决(8.x,,5.x)

首先强调的是两个版本,5版本和8版本问题反馈不一样

Linux系统部署mysql8.4版本

MySQL官网地址写的很清楚了,不多介绍

直接进入主题,恶心了我三个多小时的问题,翻阅大量国内外资料,结果并不是个多么难得问题,心态崩了

赶紧记录。。

mysql5.x版本授权

bash 复制代码
grant all privileges on *.* to testuser@"192.168.1.100" identified by "123456" ;  //设置用户testuser,只能在客户端IP为192.168.1.100上才能远程访问mysql ;
bash 复制代码
flush privileges;

再去连接就可以了

mysql8.x

bash 复制代码
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
bash 复制代码
GRANT ALL PRIVILEGES ON *.* TO 'root'@'your_remote_ip' WITH GRANT OPTION;

来看报错

bash 复制代码
mysql> grant all privileges on *.* to "root"@"%" identified by "Abc#12341" ;
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 "Abc#12341"' at line 1
bash 复制代码
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
ERROR 1410 (42000): You are not allowed to create a user with GRANT

最后搜到的解决方式就是直接update user去更改,

据说是不允许通过root@'%',这种写法,

必须写host才可以

相关推荐
toooooop816 小时前
如何用 ss + ps 精准定位本机 Redis 的“隐形”消费者?
linux·数据库·redis·缓存
spider_xcxc16 小时前
Argo CD App of Apps 模式深度解析:像管理应用一样管理应用
大数据·数据库·elasticsearch
snow@li19 小时前
MyBatis:动态 SQL 全景梳理
数据库·sql·mybatis
360智汇云19 小时前
KV-Probe:通用 KV 数据库测试套件
数据库
x8619 小时前
我与 IT 这三十年:2015,大数据平台的重与轻
数据库·it史
BLSxiaopanlaile20 小时前
关于 select count(*)的一些总结
后端·mysql
z落落20 小时前
T-SQL 事务(Transaction)
java·数据库·sql
ClouGence21 小时前
MySQL迁移到达梦怎么做?信创数据库低停机迁移实战
数据库·sql·mysql
星空露珠21 小时前
迷你世界3.0API,事件监听
开发语言·数据结构·数据库·游戏·lua
数据库安全1 天前
灾备演练双月报|美创 DRCC 筑牢红十字医院医疗系统安全底线
数据库·安全