Can’t connect to remote MySQL server with error 61

Posted in :

遇到無法連到mysql database ,錯誤訊息代碼(61),執行畫面:


先check database 權限:
How to allow remote connection to mysql?

my.cnf (my.ini on windows)

#Replace xxx with your IP Address 
bind-address        = xxx.xxx.xxx.xxx

說明:因為安全性,所以預設只有限 localhost 連線。
Change line

 bind-address = 127.0.0.1

to

 #bind-address = 127.0.0.1

And restart the MySQL server (Unix/OSX, and Windows) for the changes to take effect.

The configuration file name and directory change in Ubuntu 16.04 The new file and location here:

/etc/mysql/mysql.conf.d/mysqld.cnf
You can edit this using:

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
OR

sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf


then

CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypass';
CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypass';

Then

GRANT ALL ON database_name.* TO 'myuser'@'localhost';
GRANT ALL ON database_name.* TO 'myuser'@'%';

檢查 mysql user account 設定指令:

SELECT User, Host FROM mysql.user;

檢查 server 上開啟的 listen port:

netstat --tcp --listen --numeric-ports

在 macOS 上操作 mysql 指令:

For those who used homebrew to install MySQL use the following commands below to start, stop, or restart MySQL

Brew start

mysql.server start

Brew restart

mysql.server restart

Brew stop

mysql.server stop

How To Install MySQL on Ubuntu 16.04:

sudo apt-get update
sudo apt-get install mysql-server
mysql_secure_installation

How To Install MySQL on macOS:

brew install mysql

接下來,是連進 mysql 裡:
Python 連 mysql
http://stackoverflow.max-everyday.com/2017/09/python-mysql/

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *