1、查看当前哪些用户可以访问
进入mysql shell
show databases;
use mysql ;
select host, user ,password from user;
mysql> select host, user ,password from user;
±----------±-----±------------------------------------------+
| host | user | password |
±----------±-----±------------------------------------------+
| localhost | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| node01 | root | |
| 127.0.0.1 | root | |
| localhost | | |
| node01 | | |
±----------±-----±------------------------------------------+
2、修改配置,在user表中添加所有用户可以访问本mysql服务
命令: grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
'root'@'%' : % 表示所有主机
root 表示主机上使用的用户
123456 表示用户所使用的密码
3、刷新生效
flush privileges;
检查更新
select host, user ,password from user;
mysql> select host, user ,password from user; ±-----
| host | user | password |
±----------±-----±------------------------------------------+
| localhost | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| node01 | root | |
| 127.0.0.1 | root | |
| localhost | | |
| node01 | | |
| % | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
±----------±-----±------------------------------------------+
% 所有主机
root 主机上使用的用户
*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 123456 加密后的数据
4、 关闭防火墙
/etc/init.d/iptables stop
chkconfig iptables off(开机不自动启动 chkconfig iptables on 开机自启)
5、远程连接