Home > Back-end >  error in mysql & after installed Laravel in docker
error in mysql & after installed Laravel in docker

Time:12-28

I installed successfully install Bitnami/Laravel

how to use MySQL in Docker? I run localhost:3306 but it's not running any ideas

CodePudding user response:

check your network, mysql container in same network with laravel container and use container name for example mysql container name is db you can in laravel env variables db:3306

CodePudding user response:

Use the network name of MySQL in the .env file. For example, if the network name of MySQL is mysql_docker, add this to the .env:

DB_HOST=mysql_docker
DB_PORT=3306

Make sure you are using the correct port. An example of MySQL configuration in the docker-compose:

 mysql_docker:
    image: mariadb:10.7.1
    restart: always
    container_name: mysql_container_name
    volumes:
      - ./mysql/data:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_DATABASE=database_name
      - MYSQL_USER=root
      - MYSQL_PASSWORD=root
    ports:
    - 127.0.0.1:3306:3306
  • Related