MySQL8 method to restrict the connection of the intranet IP segment
If the MySQL server is only used internally, some restrictions need to be made, such as restricting the connection of the specified IP segment on the intranet
The server database version is MySQL 8. Here is how to configure mysql 8 to restrict intranet IP connections
1
2
3
4
5
mysql -uroot -p //login mysql server
use mysql; //use mysql data
update user set host='192.168.1.%' where user ='root';
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.%'WITH GRANT OPTION;
systemctl restart mysql.service
Restart the MySQL server
The above configuration only allows the intranet IP segment 192.168.1. * To connect, restricting the account to root
The value of 192.168.1. *
* Is 1-254
Similarly, we can also authorize specified external network or other internal network IP segments to connect to the MySQL server.The following is a demonstration
1
2
3
4
5
6
mysql -uroot -p
use mysql;
update user set host='172.0.0.%' where user ='root';
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.0.0.%'WITH GRANT OPTION;
The IP address can also be an external network, such as 45.88.66.%
💘 相关文章
- IP 地址数据可靠来源查找供应商-IPinfo
- 一款实时监控网络IP质量的python脚本
- 在ubuntu和Debian系统单网卡绑定多个IP v6地址的方法
- 两种自动添加 ip 白名单到cloudflare的脚本
- MySQL adds the user with the least authority and the method of restricting the user to occupy system resources
- IP段到底有多少个IP?/56是多少个IP?IPv6盒IPv4度IP网段地址表示数大全
- Method to cancel ssh key password
- Configure nginx to only allow cloudflare's IP to connect to the server shell script
- nginx: [emerg] Solution to unknown directive "set_real_ip_from"
- 快速构建高可用的IP,科学上网方法