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才可以

相关推荐
fzb5QsS1p3 小时前
MySQL 事务的二阶段提交是什么?
数据库·mysql
清风徐来QCQ6 小时前
Lombok/SSM/devTools
数据库
LaughingZhu6 小时前
Product Hunt 每日热榜 | 2026-04-05
前端·数据库·人工智能·经验分享·神经网络
2601_949814697 小时前
使用mysql报Communications link failure异常解决
数据库·mysql
搜佛说7 小时前
02-第2章-核心概念与架构
数据库·物联网·微服务·架构·边缘计算·iot
#六脉神剑8 小时前
MySQL参数调优:十个关键参数助力数据库性能数倍提升
运维·mysql
C'ᴇsᴛ.小琳 ℡8 小时前
高性能NoSQL
数据库·nosql
i220818 Faiz Ul9 小时前
动漫商城|基于springboot + vue动漫商城系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·论文·毕设·动漫商城系统
iNgs IMAC9 小时前
redis 使用
数据库·redis·缓存
bearpping9 小时前
MySQL压缩版安装详细图解
android·mysql·adb