Answer the question
In order to leave comments, you need to log in
How to access MySQL installed inside Docker container?
I'm trying to access MySql installed inside a Docker container I get an
error Access denied for user 'root'@'172.18.0.5' (using password: YES)
Here's my docker-compose.yml file:
version: '2'
services:
# The Application
app:
image: app
working_dir: /var/www
volumes:
- /var/www/storage
env_file: '.env'
environment:
- "DB_HOST=database"
- "REDIS_HOST=cache"
# The Web Server
web:
image: web
ports:
- "8000:80"
# The Database
database:
image: mysql:5.7.19
volumes:
- dbdata:/var/lib/mysql
environment:
- MYSQL_DATABASE="dev"
- MYSQL_USER="root"
- MYSQL_PASSWORD="root"
- MYSQL_ROOT_PASSWORD="root"
ports:
- "3306:3306"
# redis
cache:
image: redis:3.0-alpine
volumes:
dbdata:
Answer the question
In order to leave comments, you need to log in
So you have ports forwarded (3306), connect to localhost:3306.
But if the muscle is already running locally, then change the port in the compose file.
Here you can read how to view forwarded ports:
https://docs.docker.com/engine/reference/commandli...
app:
depends_on:
- "database"
First, check access to the database from the host. You wrote above that port 3306 should be available on localhost. If your docker-compose password access works, then look at the `app` service settings, you may not be using the correct connection data there.
Well, for the `app` service, add a parameter
links:
- "database"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question