MySQL在grant时报错ERROR 1064 (42000)

网上查到的grant方式大多会报错,主要原因是MySQL版本8.0后不能再使用原来的方式

  • 查询MySQL版本
复制
SELECT version();
  • 在8.0版本下
grant all privileges on test.* to test@'%' 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 'identified by '123456'' at line 1
  • 正确的grant方式
create user test@'localhost' identified by '123456';
grant all privileges on test.* to test@'localhost';
flush privileges;
  • MySQL8.0密码登录不上
alter user test@'localhost' identified with mysql_native_password by '123456';
posted @   umichan  阅读(172)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
点击右上角即可分享
微信分享提示