Coder Social home page Coder Social logo

Comments (6)

michaelseibt avatar michaelseibt commented on June 10, 2024 1

The hint of @WhereJuly actually works:

version: "3.1"

services:
  web:
    image: mattrayner/lamp:latest-1604-php7
    environment:
      - MYSQL_USER_NAME=mysql
      - MYSQL_USER_DB=mysql
      - MYSQL_USER_PASS=mysql
    ports:
      - 8080:80
    volumes:
      - ~/mysql:/var/lib/mysql
      - .:/app

This will add a new admin user 'mysql' with the password 'mysql' and an additional database 'mysql'. Running this with docker-compose up will generate the following output when creating the MySQL instance:

web_1  | => An empty or uninitialized MySQL volume is detected in /var/lib/mysql
web_1  | => Installing MySQL ...
web_1  | => Done!
web_1  | => Waiting for confirmation of MySQL service startup
web_1  | => Creating MySQL admin user with random password
web_1  | ERROR 1133 (42000) at line 1: Can't find any matching row in the user table
web_1  | => Done!
web_1  | ========================================================================
web_1  | You can now connect to this MySQL Server with ....
web_1  |
web_1  |     mysql -uadmin -p..... -h<host> -P<port>
web_1  |
web_1  | Please remember to change the above password as soon as possible!
web_1  | MySQL user 'root' has no password but only allows local connections
web_1  |
web_1  | We also created
web_1  | A database called 'mysql' and
web_1  | a user called 'mysql' with password 'mysql'
web_1  | 'mysql' has full access on 'mysql'
web_1  | enjoy!
web_1  | ========================================================================

from docker-lamp.

pzhlkj6612 avatar pzhlkj6612 commented on June 10, 2024

What was printed when you run docker-compose logs?

from docker-lamp.

mattrayner avatar mattrayner commented on June 10, 2024

@pzhlkj6612 thanks for replying, @CamilleHUmusic - did this help you at all?

from docker-lamp.

WhereJuly avatar WhereJuly commented on June 10, 2024
  1. The solution is simple when you create the container with docker-compose and your own Dockerfile with either

    • no existing DB volume attached or
    • with DB volume when it is empty.

    After you build the container with docker-compose using Dockerfile you will get the MySQL admin password with docker logs <your-container-name-or-id>, not docker-compose logs as mentioned above.

    To avoid scrolling up, for shorter output you may filter the password with grep like this docker logs <your-container-name-or-id> | grep "MySQL Server with"

  2. However as soon as you create the container with the volume linked to the earlier created persisted database docker logs <container-name> does not provide admin user password anymore.

    In this case you have to change the admin password from command line. Anyway when building your image for the firts time you were warned to change the admin password:

    Please remember to change the above password as soon as possible!

Hope that hepls to close the issue.

from docker-lamp.

michaelseibt avatar michaelseibt commented on June 10, 2024

@CamilleHUmusic Did this thread answer your issues? A brief reply would be great. :-)

@mattrayner I suppose this can be closed, thanks for your support.

from docker-lamp.

mattrayner avatar mattrayner commented on June 10, 2024

Thanks again for jumping in here everyone :-)

from docker-lamp.

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.