0
2

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 3 years have passed since last update.

Mysql2::Error::ConnectionError: Unknown MySQL server host 'db' (-3) 解決メモ

Posted at

windowsでこれの動画の通りにやるとエラーがでてしまう箇所があって、そのエラーの解決メモ。

エラーはだいたいこんなの

Caused by:
Mysql2::Error::ConnectionError: Unknown MySQL server host 'db' (-3)
/app/bin/rails:5:in `<top (required)>'
/app/bin/spring:10:in `block in <top (required)>'
/app/bin/spring:7:in `tap'
/app/bin/spring:7:in `<top (required)>'
Tasks: TOP => db:create
(See full trace by running task with --trace)
ERROR: 1

このエラーが出た人はdocker-compose.yml

version: '3'
services:
  db:
    image: mysql:8.0
    command: --default-authentication-plugin=mysql_native_password
    volumes:
      - ./mysql-confd:/var/lib/mysql  <---この行

- ./mysql-confd:/var/lib/mysqlと書かれている部分を
- ./src/db/mysql_data:/var/lib/mysqlに書き換えてみてください。

これで僕は治りましたが、この治し方が正しいやり方なのかわからないのであくまでも応急処置といった認識でお願いします。

0
2
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
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?