Unable to connect to db using IntelliJ on mac m1.
Installed MySQL using Homebrew, I am able to access MySQL via terminal, I don't know what I am doing wrong.
I have tried reinstalling, changing the password, restarted my machine. but no hope
DBMS: MySQL (no ver.) Case sensitivity: plain=mixed, delimited=exact Connection refused
If you are encountering issues with your MySQL database while using Docker, the problem may be caused by the MYSQL_USER=root entry in your docker-compose.yaml file. This entry defines the user for your database environment and can create conflicts for the root user.
db:
image: mysql:8.0
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_HOSTS=%
- MYSQL_DATABASE=spring_boot_mysql
- MYSQL_USER=root
- MYSQL_ALLOW_EMPTY_PASSWORD=1
volumes:
- ./docker/volume_mysql:/var/lib/mysql
To resolve this issue, you should remove the MYSQL_USER=root entry and instead use one of the following to manage the root user password:
MYSQL_ROOT_PASSWORD MYSQL_ALLOW_EMPTY_PASSWORD MYSQL_RANDOM_ROOT_PASSWORD
During my search for a solution, I found that the Docker log provided a helpful error message:
[ERROR] [Entrypoint]: MYSQL_USER="root", MYSQL_USER and MYSQL_PASSWORD are for configuring a regular user and cannot be used for the root user.
By removing MYSQL_USER=root from the docker-compose.yaml file, the problem was resolved, and the database connection was established successfully.
Here is the final database definition:
db:
image: mysql:8.0
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_HOSTS=%
- MYSQL_DATABASE=spring_boot_mysql
- MYSQL_ALLOW_EMPTY_PASSWORD=1
volumes:
- ./docker/volume_mysql:/var/lib/mysql
I hope this information helps you resolve your issue.