【MySQL】8.0 执行授权语句报:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that …

场景

在 ubuntu 上使用 Docker 安装了 Mysql 8 ,远程连接一直报错

Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
  Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
  Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.

先设置 远程登录权限,在进入 docker 容器后,使用命令行客户端连接MySQL ,执行如下语句:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
-- 或者
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';

都报如下错误:

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 'INDENTIFIED WITH mysql_native_password BY '123456'' at line 1

解决方案

根据提示,应是MYSQL 版本不同,语法不同所致。MySQL 8.0.x 应使用如下语句。

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值