MySQL8的root帐号授权

执行下面的命令MySQL8会报错:

 grant all privileges on db_name.* to 'root'@'%'
  ### Cause: java.sql.SQLSyntaxErrorException: Access denied for user 'root'@'%' to database 'db_name'

解决办法:

SELECT `User`, `Grant_priv` FROM `mysql`.`user` WHERE `User` = 'root';
  UPDATE `mysql`.`user` SET `Grant_priv` = 'Y' WHERE `User` = 'root';
  grant all privileges on *.* to 'root'@'%';
  FLUSH PRIVILEGES;

MySQL8的root远程授权

CREATE USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '密码';
  GRANT ALL ON *.* TO 'root'@'%';
  FLUSH PRIVILEGES;

 

posted @ 2023-04-04 11:54  程序员老刘  阅读(259)  评论(0编辑  收藏  举报