I’m learning full_stack development by creating a project with a mysql database/express api.
My application was working “properly”, then I tried to dockerize it. I writted a docker-compose file : `version: ‘3’
services:
db:
image: mysql:latest
command: –bind-address=’0.0.0.0′
container_name: mysql_db
ports:
– “3306:3306”
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: housesdb
MYSQL_PASSWORD: password
volumes:
– app-data:/var/lib/mysql
networks:
– my-network
api:
build: ./Backend
container_name: node_api
ports:
– “3005:3005”
environment:
DB_HOST: db
DB_PORT: 3306
DB_USER: root
DB_PASSWORD: password
DB_NAME: housesdb
depends_on:
– db
networks:
– my-network
web:
build: ./frontend-jm
container_name: react_app
ports:
– “3000:3000”
depends_on:
- db
- api
networks:
- my-network
networks:
my-network:
driver: bridge
volumes:
app-data:`
Now the problem is that my node.js API have “ECONNREFUSED” error while trying to get a connection with the mysql container.
Note that I can connect to mysql database with MySqlWorkbench from my host.
At the first place, I thought that mysql was blocking access from app when the app address wasn’t localhost. To verify it, I started a mysql container like this :
docker run -it --rm mysql:tag --verbose --help
but I can see that the value “bind-address” from the configuration file of mysql is “*” in the terminal.
After I made some research, I tried this command :
alter user 'root'@'%' identified with mysql_native_password by 'password'
And I then had this error : “Error Code: 1524. Plugin ‘mysql_native_password’ is not loaded”.
Can someone help me please ?
Thank’s a lot, have a nice day.
Drose is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.