windows連接虛擬機linux下mysql配置

在虛擬機裏安裝好ubuntu後,網絡連接方式需要選擇 bridge

這樣方便設置ubuntu的ip等。

然後就開始Mysql的遠程訪問

要通過遠程連接MySQL,需要做兩步:

第一步是要創建一個可以遠程連接的 MySQL 用戶

mysql> GRANT ALL PRIVILEGES ON remote.* TO remote@"%" IDENTIFIED BY "remotepwd";

第二步是要修改 mysql 的配置文件 /etc/mysql/my.cnf

$> sudo vi /etc/mysql/my.cnf

在舊版本中找到 skip-networking,把它註釋掉就可以了 
#skip-networking

在新版本中:
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1

bind-address = 127.0.0.1 這一行要註釋掉
#bind-address = 127.0.0.1

或者把允許訪問的 ip 填上
#bind-address = 192.168.1.100

然後重啓 MySQL
$> sudo /etc/init.d/mysql restart
* Starting MySQL database server mysqld
  ...done.
* Checking for corrupt, not cleanly closed and upgrade needing tables.
andy@ubuntu:~$ sudo /etc/init.d/mysql start
* Starting MySQL database server mysqld
  ...done.

這樣就可以遠程訪問 MySQL 了
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章