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

How to grant all privileges to root user in MySQL 8.0(如何在 MySQL 8.0 中授予 root 用户所有权限)
本文介绍了如何在 MySQL 8.0 中授予 root 用户所有权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试过

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

获取

ERROR 1064 (42000):您的 SQL 语法有错误;检查手册对应于您的 MySQL 服务器版本,以便在第 1 行的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.

注意:在以前的版本中尝试时也是如此.

Note: The same is working when tried in previous versions.

也试过了

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

获取

ERROR 1410 (42000):您不能使用 GRANT 创建用户

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

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

MySQL (8.0.11.0) username/password is root/root.

推荐答案

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

Starting with MySQL 8 you no longer can (implicitly) create a user using the GRANT command. Use CREATE USER instead, followed by the GRANT statement:

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

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

Caution about the security risks about WITH GRANT OPTION, see:

  • 授予所有数据库权限

这篇关于如何在 MySQL 8.0 中授予 root 用户所有权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)
SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)