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