环境:RHEL 5.3

安装了MySQL之后,MySQL的root用户默认是不开放远程访问权限的。为了开放它,只需要两步:

 

用Linux系统的root用户登录系统,然后:

 

(1)开放3306端口的远程连接权限:

在“-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited”这一行的上面(注意,一定是上面),添加如下一行:

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

 

然后重启iptables:

[root@localhost ~]# service iptables restart

 

(2)为MySQL的root用户添加远程访问权限:

[root@localhost ~]# mysql -uroot -p
Enter password: (此处输入密码登录)
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 35 to server version: 5.0.22

Type 'help;' or '/h' for help. Type '/c' to clear the buffer.

 

 

mysql> grant all on *.* to root@'%' identified by 'your_password';               
Query OK, 0 rows affected (0.01 sec)

 

mysql> exit
Bye

 

[root@localhost ~]# /etc/init.d/mysql restart

 

 

搞定。

Logo

更多推荐