31
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

docker + mysql が接続できない / Access denied for user 'root'@'172.18.0.5' (using password: YES)

Posted at

問題

db のコンテナを立ててアプリからつなぐ際に、接続ができない。rails から db createできない

ログ

Access denied for user 'root'@'172.18.0.5' (using password: YES)
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "reconnect"=>false, "pool"=>5, "timeout"=>5000, "host"=>"db", "username"=>"root", "password"=>"pass", "port"=>3306,

docker logs

Version: '5.7.22'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)
2018-06-29T01:49:15.357922Z 2 [Note] Access denied for user 'root'@'172.18.0.3' (using password: YES)
2018-06-29T01:49:50.804587Z 3 [Note] Access denied for user 'root'@'172.18.0.5' (using password: YES)
2018-06-29T01:49:54.664363Z 4 [Note] Access denied for user 'root'@'172.18.0.5' (using password: YES)

docker-compose.yml

version: '3'
services:
  db:
    image: mysql:5.7
    environment:
      - MYSQL_ROOT_PASSWORD=pass
    ports:
      - '3306:3306'
    volumes:
      - db-data:/var/lib/mysql

Access denied for user 'root'@'172.18.0.5' (using password: YES)

やったこと

・root以外のユーザーを作成、ユーザー名、パスワードなどを変更
・5.6に変更
・再起動

解決策

volumeを消したら行けた。。
https://github.com/docker-library/mysql/issues/51

名前付きのvolumeを使っていたので
docker volume rm servicename_db-data

31
22
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
31
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?