远程连接mysql数据库的方法

xiaoxiao2025-08-29  18

1、更改数据库权限

# 登陆数据库 mysql -u root -p # 使用mysql 数据库 use mysql; # 赋予权限,第一个“*”是数据库名,第二个“*”是表名,root是用户,%代表所有ip, '123456' 是密码 grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option; # 刷新使赋予权限生效 flush privileges;

2、开放端口

# 开放3306端口 /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT # 保存iptables /etc/rc.d/init.d/iptables save # 重启iptables service iptables restart
转载请注明原文地址: https://www.6miu.com/read-5035388.html

最新回复(0)