Ubuntu 下開啟遠端連線 MySQL

2022-08-30 08:57:15 字數 1023 閱讀 3259

要通過遠端連線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 了.

ubuntu下mysql 開啟遠端連線

一 修改配置檔案 vim etc mysql my.cnf,找到 bind address 127.0.0.1 注釋掉這行,如 bind address 127.0.0.1 或者改為 bind address 0.0.0.0 允許任意ip訪問 或者自己指定乙個ip位址。重啟mysql服務 servi...

ubuntu 開啟ssh 遠端連線

1.安裝ssh服務 sudo apt get install openssh server 2.查詢ssh服務是否啟動 ps e grep ssh 3.啟動ssh服務 service ssh start 4.修改伺服器ssh配置,讓root可以登入 vim etc ssh sshd config p...

ubuntu下 mysql 遠端連線

修改遠端主機上mysql的配置檔案 sudo sucd etc mysql mysql.conf.d cp mysqld.cnf mysqld.cnf.bak 拷貝備份檔案 vim mysqld.cnf 進去後注釋掉bind address這一行 bind address 127.0.0.1,然後儲...