Mysql Error no.1130

來源:互聯網
上載者:User

mysql資料庫遠端存取設定方法

1、修改localhost
更改 "mysql" 資料庫裡的 "user" 表裡的 "host" 項,從"localhost"改成"%"
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
mysql>FLUSH PRIVILEGES;

 

2、指定授權
使用myuser/mypassword從任何主機串連到mysql伺服器:
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

使用myuser/mypassword從ip為192.168.225.166的主機串連到mysql伺服器:
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.225.166' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

 

3、泛授權
mysql -h localhost -u root
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; //賦予任何主機上以root身份訪問資料的許可權
mysql>FLUSH PRIVILEGES;

 

解決Mysql無法遠端連線的問題

1、Mysql的連接埠是否正確
通過netstat -ntlp 查看連接埠佔用情況,一般情況下連接埠是3306。在用工具串連MySQl是要用到連接埠。例如My Admin\My Query Browser\MySQl Front等。

2、檢查使用者權限是否正確
mysql庫的user表裡有兩條記錄:host分別為localhost和%(為了安全,%可以換成你需要外部串連的IP)。

3、查看/etc/mysql/my.cnf中,skip-networking 是否已被注掉
需要注掉
報錯:ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.51.112' (111)

 

sudo gedit /etc/mysql/my.cnf
#skip-external-locking

#bind-address        = 127.0.0.1

skip-name-resolve

4、查看iptables是否停掉,沒關的情況下,無法串連
通過:service iptables stop臨時關閉。
報錯:ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.51.112' (113)

相關文章

聯繫我們

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