Ubuntu Mysql开通外网访问权限
1、编辑 my.cnf 文件:
sudo vi /etc/mysql/my.cnf
2、将绑定地址行注释掉或者修改为指定 IP
#bind-address = 127.0.0.1
3、登录 MySQL:
mysql -uroot -p密码
4、添加 root 用户访问权限
grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘密码‘;
flush privileges;
5、查看 user 权限,成功修改权限为 %:
select host,user from mysql.user;
+------------+----------------+
| host | user |
+------------+----------------+
| % | root |
| 127.0.0.1 | root |
| localhost | root |
+------------+----------------+
6、重启 MySQL:
sudo /etc/init.d/mysql restart
分类: 数据库
时间: 2024-10-25 15:33:13