数据库
首页 > 数据库> > 如何在MySQL 8.0中为root用户授予所有权限

如何在MySQL 8.0中为root用户授予所有权限

作者:互联网

试着

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' 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 ‘root’ WITH GRANT OPTION’ at line 1.

注意:在以前的版本中尝试时也一样.

也试过了

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

入门

ERROR 1410 (42000): You are not allowed to create a user with GRANT

MySQL(8.0.11.0)用户名/密码是root / root.

解决方法:

从MySQL 8开始,您不再可以(隐式)使用GRANT命令创建用户.请改用CREATE USER,然后使用GRANT声明:

mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'root';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

关于WITH GRANT OPTION的安全风险的注意事项,请参阅:

> Grant all privileges on database

标签:mysql-error-1064,mysql,mysql-8-0
来源: https://codeday.me/bug/20190925/1817518.html