欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

mysql8.0创建用户授予权限时报错的问题分析和解决办法

程序员文章站 2022-05-16 18:55:23
我遇到错误一:error code: 1064. you have an error in your sql syntax; check the manual that corresponds to...

我遇到错误一: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;