解決LNMP環境下串連不上mysql的問題

來源:互聯網
上載者:User

標籤:mysql

LNMP環境下 遠端連線mysql資料庫


一、為了安全起見,lnmp環境是禁止遠端連線的,他會刪除iptables裡面的3306連接埠的防火牆規則



一、如果是phpmydmin  那要把許可權裡要遠端連線的使用者主機改成 *
參考:
https://bbs.vpser.net/thread-3135-1-1.html


或者
mysql -uroot -p  輸入密碼


use mysql;
update user set host = ‘%‘ where user=‘root‘;


flush privileges;


exit


root 可以換成我們的使用者名稱


如果沒有建立使用者,執行
grant  all privileges on 資料庫名.* to 使用者名稱@‘%‘ identified by ‘密碼‘;


如:grant all privileges on mysql.* to ‘root‘@‘%‘ identified by ‘123456‘;


將所有iptables 以序號標記顯示,執行:
iptables  -L -n --line-numbers


添加3306連接埠號碼到防火牆


iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
service iptables save


service iptables restart


service mysql restart


然後用mysqlyog串連資料庫試試,可以先用mysqlyog右下角的測試連接測試





二、為了安全起見,lnmp環境是禁止遠端連線的,他會刪除iptables裡面的3306連接埠的防火牆規則


iptables裡面刪除drop 3306連接埠


參考iptables教程
htttps://www.vpser.net/security/linux-iptables.html


要刪除已添加的iptables規則
將所有iptables 以序號標記顯示,執行:
iptables  -L -n --line-numbers


比如要刪除INPUT裡面序號為8 的規則 執行:
iptables -D INPUT 8















本文出自 “12252646” 部落格,請務必保留此出處http://12262646.blog.51cto.com/12252646/1947251

解決LNMP環境下串連不上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.