Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting to MySQL remotely #63

Closed
otrsw opened this issue Jun 5, 2019 · 5 comments
Closed

Connecting to MySQL remotely #63

otrsw opened this issue Jun 5, 2019 · 5 comments

Comments

@otrsw
Copy link

otrsw commented Jun 5, 2019

I am struggling to enable remote connection to the mysql server.

  1. MySQL running fine and I can access using the admin user via phpMyAdmin
  2. The rights for admin seem to allow all hosts (%)
  3. When trying to connect from another PC via MySQL IDE I always get 10061:Unknown error

I created the docker container with a port mapping "xxxx:3306" - so I am using the external port in my connection setup.

Do I need to do anything else to allow external connection?

@pzhlkj6612
Copy link
Contributor

I also encountered the same issue and found a temporary solution.

This is the content at the end of /var/log/mysql/error.log.

2019-06-05T14:03:33.303057Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
2019-06-05T14:03:33.303101Z 0 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
2019-06-05T14:03:33.303186Z 0 [Note] Server socket created on IP: '127.0.0.1'.
...

127.0.0.1 has been bound. Let's find its location.

$ grep -rwn /etc/ -e 'bind-address'
/etc/mysql/mysql.conf.d/mysqld.cnf:43:bind-address              = 127.0.0.1
/etc/mysql/conf.d/mysqld_innodb.cnf:6:bind-address=0.0.0.0

In /etc/mysql/mysql.conf.d/mysqld.cnf, change the value of bind-address to 0.0.0.0, or comment this line out directly.

Then, restart mysql by /etc/init.d/mysql restart. Read the log file mentioned above.

2019-06-05T14:27:05.967013Z 0 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
2019-06-05T14:27:05.967085Z 0 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
2019-06-05T14:27:05.967176Z 0 [Note] Server socket created on IP: '0.0.0.0'.
...

It works.

Ref: linux - How to bind MySQL server to more than one IP address? - Server Fault


The file /etc/mysql/conf.d/mysqld_innodb.cnf seems useless, isn't it?

@pzhlkj6612
Copy link
Contributor

pzhlkj6612 commented Jun 5, 2019

Then, restart mysql by /etc/init.d/mysql restart. Read the log file mentioned above.

It's worth noting that if I execute this command, the process of stopping mysql service always return fail.

$ /etc/init.d/mysql restart
 * Stopping MySQL database server mysqld   [fail]
 * Starting MySQL database server mysqld   [ OK ]
$ /etc/init.d/mysql status
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)'
 *

To fix it, I searched the Internet and got a solution. Find out the password of debian-sys-maint from /etc/mysql/debian.cnf, and log in MySQL as admin, then execute the sql:

GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '*the password I found*';

Go back to shell, and try restarting MySQL.

 /etc/init.d/mysql restart
 * Stopping MySQL database server mysqld   [ OK ]
 * Starting MySQL database server mysqld   No directory, logging in with HOME=/   [ OK ]

Issue solved, almost.


You can follow links below to learn more.

Ref 1: Why can’t I stop the MySQL service on Debian? - Super User

Ref 2: linux - What is the debian-sys-maint MySQL user (and more)? - Server Fault

@freeyland
Copy link

thanx!

@mattrayner
Copy link
Owner

I'm going to take a look at this over the next few days and see if I can fix it in the image

@mattrayner
Copy link
Owner

This should now be fixed in the latest release

Thanks for all your patience, if you can confirm and post back that would be amazing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants