The thing is that due to the crash, the end of the initialization was not executed, including my scripts and the databases creation along with users. The problem was not pretty visible because when launching the container a second time, the initialization was skipped, the good port was configured, and the server worked fine. The container tries to connect to MySQL and crash due to the port. I already tried a proposed solution to configure manually the port in custom.cnf but it does not work. The main clue in the logs is that line : Version: '5.7.15' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server (GPL) Now the container runs a few seconds after building, then crash. This chmod command is meant to avoid this kind of error #!bin/bashĪll this stuff is working, except that I haven't any root access, blocking me from creating databases or mysql users for my apps !ĮDIT: After days of investigation, and an issue in docker-library/mysql repository, we found out that one of the problems was a deprecated configuratio key in custom.cnf. RUN chmod a+x /my-entrypoint.sh & chown root:root /my-entrypoint.shĮNTRYPOINT RUN chmod a+x /docker-entrypoint-initdb.d/databases.sh & chown root:root /docker-entrypoint-initdb.d/databases.sh RUN dos2unix /docker-entrypoint-initdb.d/databases.sh & dos2unix /my-entrypoint.sh & dos2unix /etc/mysql/conf.d/custom.cnf & apt-get -purge remove -y dos2unix & rm -rf /var/lib/apt/lists/* RUN apt-get update & apt-get install -y dos2unixĬOPY conf.d/custom.cnf /etc/mysql/conf.d/ĬOPY docker-entrypoint-initdb.d/databases.sh /docker-entrypoint-initdb.d/databases.sh The custom entrypoint is named differently to avoid overidding the default mysql entrypoint script. The dos2unix command is meant to convert Windows line endings to Unix. Only MYSQL_ROOT_PASSWORD deserves interest (perhaps this statement is the cause of my failure to make this work.! ). Most of the environment variables are used in scripts and applications independantly from the MySQL server. In this matter I've encountered quite a problem : my MySQL container, extending the MySQL official Docker image, seems to fail to create the root account, despite the setting of the MYSQL_ROOT_PASSWORD environment variable in my docker-compose`.yml. Once the password is reset, the server is ready for use.Today I'm trying to make my Docker environment working ! Substitute password with the password of your choice. Because the MYSQL_ONETIME_PASSWORD option is true by default, after you have connected a mysql client to the server, you must reset the server root password by issuing this statement: mysql> ALTER USER IDENTIFIED BY 'password' When asked, enter the generated root password (see the instructions above on how to find it). Once you have the password by one of the above-mentioned methods, you can then login with the below command using that password docker exec -it mysql mysql -uroot -p Output of above command is: GENERATED ROOT PASSWORD: PopiKQIjAS#OGj3x]yJOBLEn80p Second Approach - Run container in daemon mode & fetch the password from logsĬheck the below command to run the container docker run -d -name=mysql mysql/mysql-server:latestĪnd then run the below command to fetch the password docker logs mysql 2>&1 | grep GENERATED Version: '8.0.20' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Communi T23:41:09.448584Z 0 CA certificate ca.pem is self signed. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060 T23:41:08.549216Z 1 InnoDB initialization has started. Password will need to be changed before database can be used. T23:41:07.861667Z 0 /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.20) MySQL Community Server - GPL. GENERATED ROOT PASSWORD: PopiKQIjAS#OGj3x]yJOBLEn80p Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Version: '8.0.20' socket: '/var/lib/mysql/mysql.sock' port: 0 MySQL Community T23:41:01.666070Z 0 CA certificate ca.pem is self signed. There are couple of ways to see the password.įirst Approach - Don't Run container in daemon modeĬheck the below command docker run -name=mysql mysql/mysql-server:latestĪnd this will print the password in the terminal as look at the below logs T23:41:01.418347Z 0 X Plugin ready for connections.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |