admin avatar

MySQL8 method to restrict the connection of the intranet IP segment

🕑 by admin





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.%





💘 相关文章


📝 有偿服务

• 服务器合租380/年
• 服务器配置:2.4G,6核12线程
• nvme raid 1硬盘
• 不提供服务器自主面板
• 适合稳定的个人博客
• 提供备份服务,备份空间自备
• 只提供ipv6地址,搭配cloudflare使用
• 提供想要安装的程序和域名
• 博客必须是和谐健康的
• 博客不能是视频和图片站
• 提供以下付费服务
• 建站,FTP,备份,Linux,Wordpress等建站问题咨询管理
• 加微信:344452500(不闲聊,直接说事)

写一条评论

Based on Golang + fastHTTP + sdb | go1.16.8 Processed in 0ms