mysql> GRANT ALL PRIVILEGES ON *.* TO yunqu@'%' WITH GRANT OPTION IDENTIFIED BY 'p@sswr0d123'; 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 'p@sswr0d123'' at line 1
时间: 2023-07-09 14:40:59 浏览: 137
这个错误的原因是语法错误,正确的语法应该是在GRANT ALL PRIVILEGES ON *.* TO yunqu@'%'后面加上一个关键字IDENTIFIED BY 'p@sswr0d123',而不是在后面另起一行。正确的语法应该是:
```mysql
GRANT ALL PRIVILEGES ON *.* TO yunqu@'%' IDENTIFIED BY 'p@sswr0d123' WITH GRANT OPTION;
```
这样就可以成功授权了。
相关问题
mysql> GRANT ALL PRIVILEGES ON *.* TO yunqu@'%' IDENTIFIED BY 'p@sswr0d123' WITH GRANT OPTION; 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 'p@sswr0d123' WITH GRANT OPTION' at line 1
这个错误的原因是语法错误,正确的语法应该是在GRANT ALL PRIVILEGES ON *.* TO yunqu@'%'后面加上一个关键字WITH GRANT OPTION,而不是在后面另起一行。正确的语法应该是:
```mysql
GRANT ALL PRIVILEGES ON *.* TO yunqu@'%' IDENTIFIED BY 'p@sswr0d123' WITH GRANT OPTION;
```
这样就可以成功授权了。
mysql> GRANT ALL PRIVILEGES ON *.* TO 'yunqu'@'%' IDENTIFIED BY 'p@sswr0d123' WITH GRANT OPTION; 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 'p@sswr0d123' WITH GRANT OPTION' at line 1怎么解决
出现这个错误可能是由于语法错误导致的,根据错误提示,可以看出是在 "IDENTIFIED BY" 这个关键字之前出现了错误。
正确的语法应该是:
```
GRANT ALL PRIVILEGES ON *.* TO 'yunqu'@'%' IDENTIFIED BY 'p@sswr0d123' WITH GRANT OPTION;
```
请注意以下几点:
1. 在 "IDENTIFIED BY" 关键字之前是用户名和主机名,中间要用 "@" 符号连接,不能有空格或其他字符。
2. 在 "IDENTIFIED BY" 关键字之后是用户的密码,要用单引号或双引号括起来。
3. 如果需要授权的用户不存在,需要先创建该用户,例如:
```
CREATE USER 'yunqu'@'%' IDENTIFIED BY 'p@sswr0d123';
```
然后再为该用户授权。
阅读全文