Linux下MySQL開放root的遠端存取許可權

來源:互聯網
上載者:User

標籤:

環境: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:

[[email protected] ~]# service iptables restart

 

(2)為MySQL的root使用者添加遠端存取許可權:

[[email protected] ~]# 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 [email protected]‘%‘ identified by ‘your_password‘;                
Query OK, 0 rows affected (0.01 sec)

 

mysql> exit
Bye

 

[[email protected] ~]# /etc/init.d/mysql restart

Linux下MySQL開放root的遠端存取許可權

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.