mysql8.0无法创建数据库 解决root无法授权问题

一种情况

mysql的赋权操作:GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘你的密码‘ WITH GRANT OPTION;

mysql赋权操作:

use mysql;

GRANT ALL PRIVILEGES ON *.* TO root@% IDENTIFIED BY 你的密码 WITH GRANT OPTION;

flush privileges;

GRANT:赋权命令

ALL PRIVILEGES:当前用户的所有权限

ON:介词

*.*:当前用户对所有数据库和表的相应操作权限

TO:介词

‘root’@’%’:权限赋给root用户,所有ip都能连接

IDENTIFIED BY ‘你的密码’:连接时输入密码,密码为 你的密码

WITH GRANT OPTION:允许级联赋权

20200901:

将GRANT语句通过代码块包起来

二种情况

mysql中远程连接权限语句grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘你的密码‘ with grant optio报错

grant all privileges on *.* to root@% identified by 你的密码 with grant option;

原因: mysql的版本问题,这条语句适用于MySQL8.0之前

解决: mysql8.0及以上版本需要使用以下语句:

use mysql;

create user root@% identified by 你的密码;

grant all on *.* to root@% with grant option;

grant all privileges on *.* to root@% with grant option;

查看当前用户所有权限

SHOW GRANTS FOR root@%;

一种情况 mysql的赋权操作:GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘你的密码‘ WITH GRANT OPTION; mysql赋权操作: use mysql; GRANT ALL PRIVILEGES ON *.* TO root@% IDENTIFIED BY 你的密码 WITH GRANT OPTION; flush privileges; GRANT:赋权命令 ALL PRIVILEGES:当前用户的所有权限 ON:介词 *.*:当前用户对所有数据库和表的相应操作权限 TO:介词 ‘root’@’%’:权限赋给root用户,所有ip都能连接 IDENTIFIED BY ‘你的密码’:连接时输入密码,密码为 你的密码 WITH GRANT OPTION:允许级联赋权 20200901: 将GRANT语句通过代码块包起来 二种情况 mysql中远程连接权限语句grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘你的密码‘ with grant optio报错 grant all privileges on *.* to root@% identified by 你的密码 with grant option; 原因: mysql的版本问题,这条语句适用于MySQL8.0之前 解决: mysql8.0及以上版本需要使用以下语句: use mysql; create user root@% identified by 你的密码; grant all on *.* to root@% with grant option; grant all privileges on *.* to root@% with grant option; 查看当前用户所有权限 SHOW GRANTS FOR root@%;
经验分享 程序员 微信小程序 职场和发展