MySQL笔记-mysql权限授权及创建用户

MySQL创建用户的方式:

1. insert into user;

2. create user;

3. grant all privileges on *.* to 'xxx'@'xxx'  identified by 'xxxxx'

演示如下:

查看user表目前存在的用户:

select user, host,passowrd from mysql.user;

增加新用户有如下几种方式

insert into mysql.user(user, host, password) values('xxx', 'xxx', password('xxx'));
flush privileges;

一般user mysql,这个mysql库是放到内存中的,这个flush privileges就会更新相爱内存。如果使用下面这个命令,就不需要flush privileges了!

扫描二维码关注公众号,回复: 11131411 查看本文章
create user ''@'' identified by '123456'

%这个是指可以从任意IP进行登录。

下面是查看权限:

show grants for 'xxxx'@'xxx';

下面是授予权限的命令,grant命令既可以授予权限,又可以创建用户

grant all privileges on *.* to 'xxxx'@'xxxx'

如果创建用户后,又授予权限:

grant all privileges on *.* to 'it1996'@'%' identified by 'it1996';

如下只授予查询权限:

grant select on xx数据库.* 'xxx'@'xxx';

删除用户,这里用户被删除后

drop user 用户名

发布了1358 篇原创文章 · 获赞 1万+ · 访问量 578万+

猜你喜欢

转载自blog.csdn.net/qq78442761/article/details/105748601
今日推荐