There could be several reasons for the "connection refused" error when attempting to connect to MySQL through Docker Compose, including:
Docker container is not running: Make sure that the container is running by using the docker ps
command.
Incorrect port number: Double-check that you are connecting to the correct port number that the MySQL container is listening on. By default, the MySQL container listens on port 3306.
Incorrect credentials: Check that you are using the correct credentials to access the MySQL database. By default, the root user has no password, but you can set one up when launching the MySQL container.
Firewall or network issues: Make sure that there are no firewall or network issues preventing the connection to the MySQL container.
Docker-compose environment settings: Ensure that the environment setting in your docker-compose.yml file matches the values your application expects. Ensure that your application is correctly directing traffic to the Compose service network.
These reasons should help you identify why you can’t connect to the MySQL database in Docker Compose.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-07-01 11:00:00 +0000
Seen: 16 times
Last updated: Feb 01 '22
How can multiple queries be merged into a single stored procedure in MySQL?
What does "waiting for handler commit" mean in relation to the slow writes experienced in MySQL 8?
How can Spring Boot and Mysql be utilized for CRUD operations?
How can I use sqlalchemy to merge JSON within a column of mysql?
Retrieve all rows in which two IDs appear for the first time.
What are the benefits of choosing sqlalchemy.types instead of sqlalchemy.dialects.mssql?