相关推荐recommended
完美解决:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to
作者:mmseoamin日期:2023-12-05

目录

一、问题:

二、原因: 

三、解决方法

四、拓展:


一、问题:

使用下列授权语句

grant all privileges on mortal.* to 'xiaoqi'@'localhost' identified by 'mortalz7' with grant option;

【mortal:数据库名  xiaoqi:用户名  localhost:主机名   mortalz7:密码】 

遇到如下问题:

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 'mortalz7' with grant option' at line 1

完美解决:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to,第1张

  

二、原因: 

ERROR 1064(42000):你的SQL语法有错误;查看与MySQL服务器版本对应的手册,在第1行'identified by 'mortalz7' with grant option'附近使用正确的语法

三、解决方法:

(1)首先是否有中文字符,确保所有字符全为英文。

(2)重新执行语句,如还是遇到同样问题,使用如下方法解决:

先创建用户,再授权

创建用户xiaoqi

create user 'xiaoqi'@'localhost' identified by 'mortalz7';

 完美解决:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to,第2张

【创建时遇到ERROR 1819 (HY000): Your password does not satisfy the current policy requirements问题,请查看http://t.csdnimg.cn/fp7tZ】 

授权:

grant all privileges on mortal.* to 'xiaoqi'@'localhost' with grant option;

完美解决:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to,第3张

刷新权限:

flush privileges;

完美解决:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to,第4张

四、拓展:

查看授权

show grants for 'xiaoqi'@'localhost';

完美解决:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to,第5张

删除用户:

drop user 'xiaoqi'@'localhost';

 完美解决:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to,第6张