Can't connect to remote MySQL server with error 61

Check if your mysql server is listening on a socket with netstat:

netstat -tulpen

and search for 3306.

If not or if only on localhost, check my.cnf and search the bind-address line and change it to:

bind-address = 0.0.0.0

then restart the server and try again.


Check status:

netstat -tulpen

Modify your configuration:

nano /etc/mysql/my.cnf
# Edit:
bind-address = 0.0.0.0

Enter mysql and give privileges:

mysql -umyuser -pmypassword
# Run:
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit

Restart mysql

/etc/init.d/mysql restart

With MySql 5.7 they changed files so bind-address are now in:

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

instead of:

/etc/mysql/my.cnf

Tags:

Mysql