mysql添加用户密码_MySQL添加用户、授权用户和修改密码

1. 修改MySQL的root用户密码

/**修改密码**/

set password for 'root'@'localhost' = password('123456');

/**修改密码**/

update mysql.user set Password = password('123456') where User='root';

/**刷新**/

flush privileges;

2.  创建用户并授权

/**创建用户**/

create user what21 identified by '123456';

/**将数据库(db_console)的所有权限授权给用户**/

grant all privileges on db_console.* to what21@localhost identified by '123456';

/**将数据库(test)的所有权限授权给用户**/

grant all privileges on test.* to what21@localhost identified by '123456';

/**授权所有权限给用户**/

grant all privileges on *.* to what21@localhost identified by '123456';

/**授权用户远程访问**/

grant all on *.* to what21@"%" identified by '123456';

/**刷新**/

flush privileges;

/**查看用户信息**/

select Host,User,Password from mysql.user;

/**修改用户密码**/

update mysql.user set Host='0.0.0.0',Password='123456' where User='what21';

3. 删除授权和用户

/**删除用户授权**/

drop user what21@'localhost';

/**删除用户**/

drop user what21;

/**删除用户**/

delete from mysql.user where User='what21';

/**查看用户信息**/

select Host,User,Password from mysql.user;

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值