mysql 的用户权限
show grants for "username"@'host';
-
添加新用户
允许本地IP访问localhost:127.0.0.1
use mysql;
create user 'test'@'localhost' identified by '123456';
允许外网IP访问
create user 'test'@'%' identified by '123456';
'%'表示对所有非本地主机的授权,不包括localhost刷新授权
flush privileges;
-
给用户分配权限
授予用户通过外网ip对于该数据库的全部权限
grant all privileges on
testdb.* to 'test'@'%' identified by '123456';授予用户在本地服务器对该数据库的全部权限
grant all privileges on
testdb.* to 'test'@'localhost' identified by '123456';授予用户通过外网IP对全部数据库的所有权限
grant all privileges on *.* to 'test'@'%' identified by '123456'; -
删除用户
delete from mysql.user where user='test' and host ='localhost';
drop user 用户名@'%';
drop user 用户名@localhost;
-
修改密码
update mysql.user set password=password('新密码') where User="test" and Host="localhost";
参考了:https://blog.csdn.net/piaocoder/article/details/53704126

浙公网安备 33010602011771号