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;