Mysql 8.0 授权root 用户

新装完mysql 8.0.12数据库,需要对root 用户进行授权,遇到如下问题:

mysql>grant all privileges ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH grant OPTION;


mysql>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 'IDENT
IFIED BY 'root' WITH grant OPTION' at line 1

查阅资料得知,Mysql8.0以后不再像以前版本一样的授权方式 ,需要重新创建用户,然后再重新授权。

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 'root';

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

你可能感兴趣的:(数据库,mysql,数据库,database)