Linux环境 Mysql新建用户和数据库并授权

  • 时间:
  • 浏览:0

flush privileges;

drop database dbtest;

delete from user where user=‘xxx’;

flush privileges;

3.执行该句后,还时需刷新权限表

8.删除数据库

完整授权:

允许本地登录

grant all privileges on dbtest. to xxx@localhost identified by "";

允许任何主机登录

grant all privileges on dbtest. to xxx@'%' identified by "";

次要授权:

grant select,update on dbtest. to xxx@localhost identified by "**";

insert into mysql.user(Host,User,Password) values("localhost","xxx",password("*"));

7.删除用户

update mysql.user set password=password(‘新密码’) where User='xxx' and Host='localhost';

flush privileges;

注释:xxx为新建用户名,*为用户密码

2.新增用户

9.修改密码

4.新建数据库并赋予用户权限

create database dbtest;

6.通过sql话语查询出新增结果

5.赋予权限,还时需再刷新权限表

1.登录mysql

flush privileges;

select user,host,password from mysql.user;