Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MYSQL_ROOT_PASSWORD not working #557

Closed
brlebtag opened this issue Apr 6, 2019 · 2 comments
Closed

MYSQL_ROOT_PASSWORD not working #557

brlebtag opened this issue Apr 6, 2019 · 2 comments
Labels
question Usability question, not directly related to an error with the image

Comments

@brlebtag
Copy link

brlebtag commented Apr 6, 2019

I'm trying to create the following database using docker-compose:

version: '3.1'
services:
mysql:
    image: mysql:5.7.21
    restart: always
    ports:
      - '3306:3306'
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
    volumes:
      - ./dbs/mysql:/var/lib/mysql

my .env:

MYSQL_ROOT_PASSWORD=password

but when I run: docker-compose up mysql

it prints:

mysql_1       | Initializing database
mysql_1       | 2019-04-06T23:10:49.591422Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
mysql_1       | 2019-04-06T23:10:51.593155Z 0 [Warning] InnoDB: New log files created, LSN=45790
mysql_1       | 2019-04-06T23:10:52.027557Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
mysql_1       | 2019-04-06T23:10:52.190840Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 39210408-58c1-11e9-8d8b-0242ac180002.
mysql_1       | 2019-04-06T23:10:52.216439Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
mysql_1       | 2019-04-06T23:10:52.217204Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

my directory (ls -lah):

-rw-r--r--  1 brlebtag bruno 1,5K Abr  6 20:10 docker-compose.yml
-rw-r--r--  1 brlebtag bruno  111 Abr  6 19:58 .env

my docker version (docker --version):

Docker version 18.09.4, build d14af54

my docker-compose version (docker-compose --version):

docker-compose version 1.24.0, build 0aa59064

I don't know why...

@wglambert
Copy link

The environment variable is passed properly and the container works as you'd expect

$ docker-compose up -d
Creating network "mysql-557_default" with the default driver
Creating mysql-557_mysql_1_b43993989be0 ... done

$ docker exec -it mysql-557_mysql_1_c15a8eaab158 bash

root@a2bee0dfac8e:/# env | grep -i password
MYSQL_ROOT_PASSWORD=password

root@a2bee0dfac8e:/# mysql -Uroot           
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

root@a2bee0dfac8e:/# mysql -Uroot -ppassword
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.21 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Apr 12, 2019
@wglambert
Copy link

The warning you're seeing in the logs:

Initializing database
. . .
root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
. . .
Database initialized

Is from:

echo 'Initializing database'
"$@" --initialize-insecure
echo 'Database initialized'

Gonna close since there isn't an issue with the image and your compose file works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

2 participants