Git Product home page Git Product logo

Comments (6)

maxhelias avatar maxhelias commented on July 29, 2024 1

Thanks @silverbackdan for the answer 😃
The issue seems to be fixed, let's close it

from symfony-docker.

younes-dev avatar younes-dev commented on July 29, 2024 1

Thank you so much @silverbackdan for your help

from symfony-docker.

silverbackdan avatar silverbackdan commented on July 29, 2024

In your DATABASE_URL try:
mysql://root:root@mysql:3306/mystore?serverVersion=5.7

the format is
mysql://username:password@host:port/database?serverVersion=x.x - in docker the host can be referred to by the service name

You should really define the MYSQL_USER and MYSQL_PASSWORD variables and use those instead though instead of the root user.

Are you aware you have both a mariadb and a mysql database service?

from symfony-docker.

younes-dev avatar younes-dev commented on July 29, 2024

thank you @silverbackis yes i do i tried with mariadb and when it failed i used mysql service

from symfony-docker.

younes-dev avatar younes-dev commented on July 29, 2024

Hey @silverbackdan thank you so much i fixed the Error its really silly but its appair very complicated when we dont know from where comes .
The problem is missing the single quotes only

 mysql:
  image: mysql:8.0
  container_name: mystore-mysql
  working_dir: /application
  volumes:
    - .:/application
  environment:
    - MYSQL_ROOT_PASSWORD= 'root'
    - MYSQL_DATABASE= 'mystore'
    - MYSQL_USER= 'root'
    - MYSQL_PASSWORD= 'root'
  ports:
    - "3308:3306"

.env file :
DATABASE_URL=mysql://root:root@mysql:3306/mystore?serverVersion=5.7

i have only one question please if you could respond me
if put the variables instead where i should put my credentials

 mysql:
  image: mysql:8.0
  container_name: mystore-mysql
  working_dir: /application
  volumes:
    - .:/application
  environment:
    MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
    MYSQL_DATABASE: ${MYSQL_DATABASE}
    MYSQL_USER: ${MYSQL_USER}
    MYSQL_PASSWORD: ${MYSQL_PASSWORD}

from symfony-docker.

silverbackdan avatar silverbackdan commented on July 29, 2024

You should choose a different username for your MYSQL_USER other than root - that should be used for a root user.

You may not need the quotes if you do not have a space either. Alternatively you can format like your second example using colons instead of the equals sign.

For your second example you can use it as you have shown or by simplifying it further

 environment:
    - MYSQL_ROOT_PASSWORD
    - MYSQL_DATABASE
    - MYSQL_USER
    - MYSQL_PASSWORD

Further reading: https://docs.docker.com/compose/environment-variables/

This will do the same thing and pass your system environment variables to the docker container.

You can either setup your system environment variables or create a .env file in the project's root directory (the same directory as the docker-compose.yaml file). Then when you run docker-compose up from the project root directory, that .env file will be used.

from symfony-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.