mysql新建库和用户linux_Linux环境 Mysql新建用户和数据库并授权-阿里云开发者社区...
1.登录mysqlmysql -u root -p2.新增用户insert into mysql.user(Host,User,Password) values("localhost","xxx",password("*"));注释:xxx为新建用户名,*为用户密码3.执行该句后,还需要刷新权限表flush privileges;4.新建数据库并赋予用户权限create database dbte
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 xxx@localhost identified by "";
允许任何主机登录
grant all privileges on dbtest. to xxx@'%' identified by "";
部分授权:
grant select,update on dbtest.to xxx@localhost identified by "**";
5.赋予权限,还需要再刷新权限表
flush privileges;
6.通过sql语句查询出新增结果
select user,host,password from mysql.user;
7.删除用户
delete from user where user=‘xxx’;
flush privileges;
8.删除数据库
drop database dbtest;
9.修改密码
update mysql.user set password=password(‘新密码’) where User='xxx' and Host='localhost';
flush privileges;
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)