Ubuntu上mysql服務遠端登入問題

2021-09-01 14:56:37 字數 1572 閱讀 7733

遠端連線ubuntu系統的mysql服務時發生錯誤 error no. 2003 can't connect to mysql server on '10.15.92.131' (10065)

進入終端命令,輸入

nmap localhost -p3306
結果為

starting nmap 5.21 ( ) at 2013-01-09 18:04 cst

nmap scan report for localhost (127.0.0.1)

host is up (0.000037s latency).

port state service

3306/tcp open mysql

以訪問的ip的替代localhost

nmap 10.15.92.131 -p3306
結果為

starting nmap 5.21 ( ) at 2013-01-09 18:04 cst

nmap scan report for 10.15.92.131

host is up (0.000045s latency).

port state service

3306/tcp closed mysql

兩相對比可以看出直接用ip連線的3306/tcp is closed

之後進入mysql命令列後,檢視登入使用者有無遠端連線的許可權

use mysql

select host,user from user

如果host為%,則此處正確

+------------------------+------------------+

| host | user |

+------------------------+------------------+

| % | lace |

| % | root |

| 10.15.92.131 | root |

| baowp-work-lenovo-b460 | |

| localhost | debian-sys-maint |

+------------------------+------------------+

退出mysql命令列,再編輯mysql的配置檔案my.cnf

sudo vi /etc/mysql/my.cnf
修改 bind-address   = 127.0.0.1 為 bind-address   = 0.0.0.0

最後重啟mysql

sudo /etc/init.d/mysql restart
再檢視 nmap 10.15.92.131 -p3306時看到3306/tcp open mysql,此時可以遠端登入

starting nmap 5.21 ( ) at 2013-01-09 18:04 cst

nmap scan report for 10.15.92.131

host is up (0.000045s latency).

port state service

3306/tcp closed mysql

ubuntu12 04 配置mysql允許遠端訪問

首先,修改 etc mysql目錄下面的my.cnf檔案,把其中的bind address設定為你的ip,假設為192.168.0.240 bash bind address 192.168.0.240 bash 我的mysql 版本如下 bash mysql ver 14.14 distrib 5...

Ubuntu上MySQL安裝指南

要安裝 mysql,可以在終端提示符後執行下列命令 sudo apt get install mysql server sudo apt get install mysql client sudo apt get install php5 mysql 安裝php5 mysql 是將php和mysql...

Ubuntu上徹底刪除MySQL

做個記錄 1 刪除 mysql 1sudo apt get autoremove purge mysql server 5.0 2sudo apt get remove mysql server 3sudo apt get autoremove mysql server 4sudo apt get ...