mysql8.0创建用户授予权限报错解决方法

我遇到错误一:Error Code: 1064. 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 ‘11111” at line 1;我遇到的错误二:Error Code: 1396. Operation CREATE USER failed for ‘u10’@’localhost’

会报错的写法:
CREATE USER ‘w’@’localhost’ IDENTIFIED BY ‘000000’;
GRANT ALL PRIVILEGES
ON .
TO ‘w’@’localhost’
IDENTIFIED BY ‘000000’;

以下是正确的写法:

create user ‘tom’@’localhost’ identified by ‘123123’;
grant all privileges on . to ‘tom’@’localhost’ ;

可见,在授权的语句中需要去掉
IDENTIFIED BY ‘password’;

单独授予某种权限的写法:
GRANT SELECT
ON oilsystem.input
TO ‘u5’@’localhost’

刷新权限并查看权限的写法:
FLUSH PRIVILEGES;
select * from user;

注意:在创建用户前需要加一句
Use mysql;

另外,收回某种权限的写法是:
REVOKE select
ON .
FROM ‘u1’@’localhost’;

打赏
Bookmark the permalink.
0 0 投票数
文章评分
订阅评论
提醒
guest

0 评论
内联反馈
查看所有评论