300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > linux为mysql用户授权 Linux环境 Mysql新建用户和数据库并授权

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

时间:2021-03-20 12:36:24

相关推荐

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

1.登录MysqL

#MysqL -u root -p

2.新增用户

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

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

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

flush privileges;

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

create database dbtest;

全部授权:

允许本地登录

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

允许任何主机登录

grant all privileges on dbtest. to [emailprotected]‘%‘ identified by "";

部分授权:

grant select,update on dbtest.* to [emailprotected] identified by "***";

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

flush privileges;

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

select user,host,password from MysqL.user;

delete from user where user=‘xxx’;

flush privileges;

drop database dbtest;

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

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。