首先强调的是两个版本,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才可以