龍巖易富通網(wǎng)絡(luò)科技有限公司

龍巖小程序開發(fā),龍巖分銷系統(tǒng)

如何開通mysql遠程連接設(shè)置

2015.09.10 | 612閱讀 | 0條評論 | 數(shù)據(jù)庫

mysql數(shù)據(jù)庫遠程訪問設(shè)置方法   1、修改localhost 更改 "mysql" 數(shù)據(jù)庫里的 "user" 表里的 "host" 項,從"localhost"改成"%" mysql>use mysql; mysql>update user set host = '%' where user = 'root'; mysql>select host, user from user; mysql>FLUSH PRIVILEGES; 2、指定授權(quán) 使用myuser/mypassword從任何主機連接到mysql服務(wù)器: GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION; 使用myuser/mypassword從ip為192.168.1.250的主機連接到mysql服務(wù)器: GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.250' IDENTIFIED BY 'mypassword' WITH GRANT OPTION; 3、泛授權(quán) mysql -h localhost -u root mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; //賦予任何主機上以root身份訪問數(shù)據(jù)的權(quán)限 mysql>FLUSH PRIVILEGES;   解決Mysql無法遠程連接的問題 1、Mysql的端口是否正確 通過netstat -ntlp 查看端口占用情況,一般情況下端口是3306。在用工具連接MySQl是要用到端口。例如My Admin\My Query Browser\MySQl Front等。 2、檢查用戶權(quán)限是否正確 mysql庫的user表里有兩條記錄:host分別為localhost和%(為了安全,%可以換成你需要外部連接的IP)。 3、查看/etc/mysql/my.cnf中,skip-networking 是否已被注掉 需要注掉 報錯:ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.250' (111) sudo gedit /etc/mysql/my.cnf #skip-external-locking #bind-address??????? = 127.0.0.1 skip-name-resolve 4、查看iptables是否停掉,沒關(guān)的情況下,無法連接 通過:service iptables stop臨時關(guān)閉。 報錯:ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.250' (113)  

贊 (

發(fā)表評論