MySQL版本8.0.11在创建账户并授予select权限遇到错误ERROR 1064 (42000)

MySQL版本8.0.11遇到错误ERROR 1064 (42000):

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 'identified by '123456'' at line 1

会报错的写法: 

grant select on *.* to 'laowang'@'localhost' identified by '123456';

这种报错是因为MySQL版本是8.0.11,而在之前的MySQL版本5.7.13就不会出现此类问题


以下是MySQL版本8.0.11正确的写法:

create user 'laowang'@'localhost' identified by '123456';

grant select privileges on *.* to 'laowang'@'localhost';



刷新权限并查看权限的写法: 

flush Privileges;  

select * from user;

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

另外,收回某种权限的写法是: 
revoke select  on *.* from 'laowang'@’localhost’;

猜你喜欢

转载自blog.csdn.net/yanpenggong/article/details/80964081