Linux系統MySQL資料庫遠程設定

來源:互聯網
上載者:User

Linux系統MySQL資料庫遠程設定

1.啟動服務和登陸 
[root@localhost ~]# /etc/init.d/mysqld restart
Stopping mysqld:                                          [  OK  ]
Starting mysqld:                                          [  OK  ]
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.66 Source distribution
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

2.授權一個可以遠程登陸的使用者
mysql> grant all privileges on *.* to tong@'%' identified by 'system';    --建立一個遠端使用者
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;    --更新許可權
Query OK, 0 rows affected (0.00 sec)
mysql>

3.關閉防火牆
[root@localhost ~]# /etc/init.d/iptables stop
iptables: Flushing firewall rules:                        [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                              [  OK  ]
[root@localhost ~]#

4.用用戶端工具可以登陸了
C:\Users\Administrator>mysql -h 遠程IP -u tong -p    --tong是遠端使用者名
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 32
Server version: 5.5.19 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

錯誤處理:

(1)防火牆沒有關閉或防火牆沒有過濾3306連接埠

圖:


         
解決方案:   

[root@localhost ~]# /etc/init.d/iptables stop
iptables: Flushing firewall rules:                        [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                              [  OK  ]
[root@localhost ~]#

或者:

[root@localhost ~]# vim /etc/sysconfig/iptables    --添加以下一行
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

(2)密碼輸入錯誤

圖:


       
解決方案:輸入正確的密碼,如果密碼忘記了在伺服器系統裡修改一下

Linux 下MySQL的安裝和遠程設定

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.