Docker Community Forums

Share and learn in the Docker community.

Mysql docker container refusing connection from outside

Hello! I try to deploy the mysql docker container on my localhost. First, I pull mysql/mysql-server:latest from docker hub. The mysql docker/docker-server image is generated well. And the container of mysql docker runs without errors. But the problem is the connection fails. With mysql workbench, the ping command is ok and client connection works successfully. But any sql command does not executed at all. Even the ‘use test’ command brings the following error message,

Error Code: 1142 SELECT command denied to user 'root'@'172.17.0.1' for table 'user_variables_by_thread'

I think this is the matter of privilege of mysql docker container. But I have no idea. Any advice, please.

Did you set the MYSQL_ROOT_PASSWORD environment variable when you started the container for the first time? First time means the very first time, when the db wasn’t initialized yet.

Thank you for your reply. Yes, I did. Before make the container, I set the MYSQL_ROOT_PASSWORD. The container was built and run successfully.

Now I realize that you use the ‘mysql/mysql-server’ and not the ‘mysql’ image and I was speaking about the second one. There is a description in the docs for this image about how to get the automatically generated root password and how to change it. You probably have no access anymore to the required container log.
Maybe the easiest at this point is to wipe out the data volume and start again with the Docker official image for MySQL.