欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Mysql配置白名单

程序员文章站 2022-05-18 20:45:53
...

1.登录mysql并进入命令行操作

mysql -u root -p

2.如果赋予该ip下该用户所有权限

grant all on *.* to 'username'@'ip' identified by 'password' with grant option;

例如:

grant all on *.* to 'root'@'192.168.1.111' identified by '[email protected]' with grant option;

如果是赋予部分权限,可以如下:

grant select,create,drop,update,alter on *.* to 'username'@'ip' identified by 'password' with grant option;

3.删除白名单用户的权限

DELETE FROM user WHERE User='username' and Host='ip';

这步慎做,删错了就登不上mysql了

4.刷新权限

FLUSH PRIVILEGES;