#Docker Connection Error via TypeORM

13 messages · Page 1 of 1 (latest)

wintry snow
#

On my Win11 computer, I'm not able to connect to our "live" dev db. So, I'm trying to use Docker as a placeholder for dev and testing.

Docker compose is setup, and the config env variables are matching the docker config, but I'm getting an error when trying to connect to the DB. Any ideas on what needs to be updated?

#

Error:

[Nest] 87868  - 10/12/2022, 2:17:03 PM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)...
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
#

docker-compose.yml

version: '3.8'
services:
  dev-db:
    image: mysql
    restart: always
    ports:
      - '3306:3306'
    expose:
      - '3306'
    environment:
      MYSQL_ROOT_PASSWORD: dev
      MYSQL_DATABASE: dev-db
      MYSQL_USER: dev
      MYSQL_PASSWORD: dev
#

config.dev.env

# MySQL DB Connection Details
DB_HOST='localhost'
DB_PORT=3306
DB_USERNAME='dev'
DB_PASSWORD='dev'
DB_NAME='dev-db'
#

The "mysql" image is a fresh install, and the docker desktop is running with the container.

fervent heart
river nova
wintry snow
wintry snow
river nova
wintry snow
wind jungle
#

There was a change in MySQL's default authentication method in v8, and some libraries have not yet landed the support: https://github.com/mysqljs/mysql/pull/2233
You can also change the auth method back for your docker db: https://stackoverflow.com/a/59228365/2078771
I believe this will need you to clear the docker volumes too, since your DB will already be initialised with the newer option. alert destructive: docker dompose down --volumes