mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your_password' WITH GRANT OPTION;FLUSH PRIVILEGES; 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 'your_password' WITH GRANT OPTION' at line 1 Query OK, 0 rows affected (0.00 sec) mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'%'
时间: 2023-08-06 18:05:46 浏览: 345
MYSQL_root密码错误
5星 · 资源好评率100%
根据错误提示,可能是因为你的 MySQL 版本不支持使用 `IDENTIFIED WITH` 语句。请尝试使用以下语句替换原来的语句:
```
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your_password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
ALTER USER 'root'@'%' IDENTIFIED BY '123456';
FLUSH PRIVILEGES;
```
这将为 root 用户授予所有权限,并将密码更改为 `your_password`,然后再将密码更改为 `123456`。注意,最后两个 `FLUSH PRIVILEGES` 语句是必需的,以便使更改生效。
阅读全文