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

  • 时间:
  • 浏览:1
  • 来源:uu快3app赚钱_uu快3大小计划注册

1.登录mysql

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

create database dbtest;

select user,host,password from mysql.user;

5.赋予权限,还前要再刷新权限表

全版授权:

允许本地登录

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 "**";

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

flush privileges;

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

flush privileges;

2.新增用户

7.删除用户

delete from user where user=‘xxx’;

flush privileges;

3.执行该句后,还前要刷新权限表

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

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

8.删除数据库

flush privileges;

drop database dbtest;

9.修改密码