xaos_xv
xaos_xv

Reputation: 769

Docker, MySQL - Error 1045, Access denied for use root

I've just started learning docker and I want to dockerize my Golang project but I get this error when I want to use MySQL: Error 1045: Access denied for use 'root'@'192.168.32.3' (using password: YES).

Here is my docker-compose.yml:

version: '3.1'

services:
  x-media-service:
    build: .
    restart: always
    ports:
      - 8000:8000
    links:
      - db
    environment:
      - "DB_PORT=3306"
      - "DB_HOST=db"
      - "DB_NAME=xmedia"
      - "DB_PASS=password"
      - "JWT_SECRET=secret"
      - VIDEO_DIR=/data/movies
      - MOVIES_SUB_DIR=/data/sub
    volumes:
      - /home/user/Movies:/data/movies
      - /home/user/Movies/sub:/data/sub

  db:
    image: mysql:5.7
    ports:
      - 6603:3306
    environment:
      - "MYSQL_ROOT_PASSWORD=root"

Upvotes: 0

Views: 564

Answers (1)

xaos_xv
xaos_xv

Reputation: 769

In my Go code I'm using root user to login into MySQL. I changed DB_PASS in x-media-service to same as MYSQL_ROOT_PASSWORD in db service. Now everything is working.

Upvotes: 0

Related Questions