skip to Main Content

I can’t connect my directus project with mysql server.
Getting connection refused error.

However when I’m running this command, I’m able to connect: mysql -u root -p -h localhost -P 3306

My docker-compose.yml file:

version: '3'
services:
 directus:
  container_name: directus
  image: directus/directus:latest
  ports:
    - 8055:8055
  environment:
   KEY: '255d861b-5ea1-5996-9aa3-922530ec40b1'
   SECRET: '6116487b-cda1-52c2-b5b5-c8022c45e263'
   DB_CLIENT: 'mysql'
   DB_HOST: 'localhost'
   DB_PORT: '3306'
   DB_DATABASE: 'directus'
   DB_USER: 'root'
   DB_PASSWORD: 'Hitman959.....'
   MYSQL_ROOT_PASSWORD: 'Hitman959.....'
   MYSQL_USER: 'root'
   MYSQL_PASSWORD: 'Hitman959.....'
   MYSQL_DATABASE: 'directus'
   ADMIN_EMAIL: '[email protected]'
   ADMIN_PASSWORD: 'admin'
 networks:
  directus:

2

Answers


  1. I actually faced the same issue and after terrible search finally I made the solution.

    You can connect to mysql by using this modified code:

    version: '3.8'
    services:
     mysql:
      image: mysql:5.7
      container_name: mysql
      restart: always
      environment:
       MYSQL_ROOT_PASSWORD: 'Hitman959.....'
       MYSQL_DATABASE: 'directus'
      ports:
       - "3306:3306"
    
     directus:
      image: directus/directus:latest
      container_name: directus
      restart: always
      ports:
       - "8055:8055"
      environment:
       KEY: '255d861b-5ea1-5996-9aa3-922530ec40b1'
       SECRET: '6116487b-cda1-52c2-b5b5-c8022c45e263'
       DB_CLIENT: 'mysql'
       DB_HOST: 'mysql'
       DB_PORT: '3306'
       DB_DATABASE: 'directus'
       DB_USER: 'root'
       DB_PASSWORD: 'Hitman959.....'
       ADMIN_EMAIL: '[email protected]'
       ADMIN_PASSWORD: 'admin'
      depends_on:
       - mysql
    
    networks:
     default:
      name: directus_network
    
    Login or Signup to reply.
  2. change password ) key and secret)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search