ubuntu下mysql遠端連線問題

2021-06-06 12:21:14 字數 972 閱讀 2837

dbcp連線mysql ip位址127.0.0.1連線可以換成本地真正ip報

org.apache.tomcat.dbcp.dbcp.sqlnestedexception: cannot create poolableconnectionfactory

網上說可能連線關閉了需要重新連線

在connection中的url引數最後加入?autoreconnect=true

結果錯誤

nested exception is org.apache.commons.dbcp.sqlnestedexception: cannot create poolableconnectionfactory (could not create connection to database server. attempted reconnect 3 times. giving up.)

還是連不上

鬱悶中然後利用mysql -uroot -p -h 真正ip連mysql報錯

mysql error number 2003   

can't connect to mysql server ***.***.***.*** (10061)

噢終於明白了,遠端埠mysql不認,真***

原來在ubuntu 9.04中預設安裝了mysql,預設只能本地訪問,如果遠端訪問需要另外設定

解決辦法:

授權允許遠端機器以指定使用者訪問

grant all privileges on *.* to root@ identified by "root";

重啟mysql

/etc/init.d/mysql restart

重新登入

mysql -uroot -p -h ip

還是不行

修改mysql配置檔案

vi /etc/mysql/my.cnf

bind-address = 127.0.0.1注釋掉

重啟mysql 成功

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,然後儲...

mysql連庫 mysql遠端連庫

mysql連線遠端庫 伺服器端 1 登陸伺服器端,進入命令列,windows cmd 2 設定使用者 密碼讓指定的ip訪問 mysql u root p 或安裝的快捷方式進入 mysql command line client,使用grant命令 grant 許可權1,許可權2,許可權n on 資料...

允許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 sudo etc ini...