2011年6月23日

Q: MySQL無法由其他PC經由MySql ODBC連入

狀況說明:
1. PC1 = Ubuntu 11.04 (MySql) v.s. PC2=Win 7 (MySql ODBC Connector)
2. 但PC2可以經由瀏覽器指定MySql主機ip方式登入


A: 綜和拜讀各家說法, 與實做之後, 歸納的步驟如下
主要作業在PC1上
Step 1 : 切換至Ubuntu的root使用者
Step 2 : gedit 改 /etc/mysql/my.cnf
Step 3 : my.cnf之內容變更如下
# skip-external-locking
# bind-address = 127.0.0.1
Step 4 : 用phpMyAdmin登入
Step 5 : Home->權限->編輯root權限 (注意, 此時主機=localhost)->主機=% (任何主機均可能登入之意)
Step 6 : 在PC2測試是否能夠連入PC1's mySql...OK


Reference
1. 有網友提出修改my.cnf
(http://tw.myblog.yahoo.com/s10274chen/article?mid=637)
透過MySQL管理程式仍無法連線,出現的錯誤訊息與用VB範例程式出現的是一樣的。
用phpMyAdmin卻可以。
在伺服器本機也可以連線。
找了一些資料,發現只要修改在/etc/mysql/目錄底下的my.cnf檔案,便可解決。切換路徑。
黃色底線那兩行,原始預設沒有加上註解,把註解加上去,然後存檔。
# skip-external-locking
# bind-address = 127.0.0.1
=> Stephen: 改了, 還是不行

2. 有網友提出檢查Listen
(http://godleon.blogspot.com/2007/07/ubuntu-mysql-server.html)
解決外部網路無法連到 Ubuntu MySQL server 的問題
今天在 Ubuntu 上裝了 MySQL server....
當帳號密碼都設定完成後,卻發現沒辦法從外部透過 mysql 指令連入,於是下了以下指令檢查:
user@ubuntu:~$ netstat -utlnp
(No info could be read for "-p": geteuid()=1000 but you should be root.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
原來只針對 127.0.0.1 作 listen,難怪外部連不進來...
而解決方法就是在 MySQL 的設定檔(在 Ubuntu 中為 /etc/mysql/my.cnf)中找到以下此行,並將其註解:
bind-address = 127.0.0.1
再次重新 MySQL 後,問題就解決囉!
=> Stephen: 其實作法與(1)相同, 但問題是, 改了my.cnf後, 仍呈現上述的訊息, 代表沒改成??但打開my.cnf, 的確是改了阿?? 因此, 產生一個新問題, 從phpMyAdmin登入主機後, 檢查"資訊->skip external locking"還是On

3. 遠程登陸不了ubuntu上的mysql的解決辦法

http://tremendousturtle.iteye.com/blog/584061
關鍵在"方法二、直接授權(推薦)" 出現
從任何主機上使用root用戶,密碼:youpassword(你的root密碼)連接到mysql服務器:
# mysql -u root -proot 
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'youpassword' WITH GRANT OPTION;

=> Stephen
(1) 進入 phpMyAdmin->權限->變更root權限->主機=% (任何主機均可能登入之意)


=> Stephen
(1) 進入 phpMyAdmin->權限->變更root權限->主機=% (任何主機均可能登入之意)

沒有留言: