mysql数据库修改用户权限

1、登陆:mysql -u root -p

2、查看现有用户:select host ,user ,authentication_string from mysql.user;

3、新建用户:create user 'username'@'host' identified by 'password'

eg: create user "testuser"@'host' identified by "123456"

4、删除用户:drop user "username"@"localhost"

5、修改用户权限

grant  权限 on 数据库名.表名 to 'username'@"localhost";

eg: grant select on testdatase.* to 'user1'@'localhost';  //给user1用户添加对testdatabse数据库的查权限。

flush privileges  //刷新权限

6、查看权限

show grant for 'username'@'%'

7、删除权限

revoke select on testdatase.* to 'user1'@'localhost';

8、更改用户名:rename user 'user1'@'localhost' to 'user2'@'localhost'

9、修改密码:set password for "username"@'localhost' = password('123456')

10、pymysql 连接数据库报错:connect database failed, (1045, "Access denied for user 'user1'@'192.168.31.124' (using passwor

只要重新去改一下user1的密码:set password for "user1"@'localhost' = password('123456')

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值