Linux 下MySQL的安裝和遠程設定

來源:互聯網
上載者:User

1. Linux 下安裝mysql很簡單
#apt-get install mysql-server-5.0
安裝完了就是設定密碼,假如密碼為'sa'

2.安裝完成後,在本機登入
#mysql -u root -p
然後輸入密碼
這樣一般都正常  【6688電子商務網站 www.6688.cc 】

可是最近發現一個問題,在本機登入正常可是在其它電腦,連到linux的mysql總是報
Can’t connect to MySQL server on ‘192.168.162.129′ (10061)的錯誤
192.168.162.129這是linux的ip,linux上ping外網正常,外網ping這台linux也正常,可就是連不上

後來經過網上尋找,原來在/etc/mysql/my.cnf檔案裡有配置一句
bind-address = 127.0.0.1
這句話的意思是,處於安全考慮,只聽原生串連
網上說的解決辦法是把此句註解掉,或者改為 bind-address = 0.0.0.0

可是當我把那一行註解掉後,
我再用我的xp上的mysql administrator連linux上的mysql時,這時換了一個錯誤
1130 Host 'XX.XX.XX.XX'is not allowed to connect to the mysql server

這是因為mysql預設不讓遠端連線
此時需要給這一個host授權

此時有兩種方式
一是 用grant授權的方式
假如要192.168.1.91授權
先進到mysql裡
然後用
mysql#>GRANT ALL PRIVILEGES ON *.* TO 'root'@'92.168.1.91' IDENTIFIED BY 'youpassword' WITH GRANT OPTION;
修改完記得用flsh一下privileges
mysql>flush privileges

二是用修改表
mysql>update user set host = '%' where user = 'root';
mysql>flush privileges;
然後再用xp的mysql administrator串連,就正常了。 

相關文章

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.