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’)

    原文作者:胖子呀
    原文地址: https://blog.csdn.net/fanzirong_/article/details/104370376
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞