Comments (6)
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.
What was printed when you run docker-compose logs
?
from docker-lamp.
@pzhlkj6612 thanks for replying, @CamilleHUmusic - did this help you at all?
from docker-lamp.
-
The solution is simple when you create the container with
docker-compose
and your ownDockerfile
with either- no existing DB volume attached or
- with DB volume when it is empty.
After you build the container with
docker-compose
usingDockerfile
you will get the MySQL admin password withdocker logs <your-container-name-or-id>
, notdocker-compose logs
as mentioned above.To avoid scrolling up, for shorter output you may filter the password with
grep
like thisdocker logs <your-container-name-or-id> | grep "MySQL Server with"
-
However as soon as you create the container with the volume linked to the earlier created persisted database
docker logs <container-name>
does not provideadmin
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 theadmin
password:Please remember to change the above password as soon as possible!
Hope that hepls to close the issue.
from docker-lamp.
@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.
Thanks again for jumping in here everyone :-)
from docker-lamp.
Related Issues (20)
- chown: cannot read directory '/app': Permission denied HOT 7
- bind-address override not working if using docker-compose HOT 1
- Waiting for confirmation of MySQL service startup HOT 8
- Setting up the container inside WSL HOT 1
- php.ini resets when container restarts HOT 1
- PHP 8 will be installed on Ubuntu 18.04 HOT 1
- 000-default.conf + htaccess, rewrite HOT 6
- MySQL won't start HOT 6
- Noob mysql question
- SQL syntax error HOT 1
- Slow startup HOT 2
- Running on Synology with Portainer HOT 3
- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) HOT 1
- Changing webserver port, mysql HOT 3
- Need ARM build target
- Gitlab CI connect to local MySQL server HOT 2
- commit save and restore HOT 1
- is port 443 functional? , I want to enable port 443, as i do? HOT 1
- "apache2 entered FATAL state, too many start retries too quickly" HOT 9
- ARM is now default. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docker-lamp.