Hi,
I tried to get your container to work but I can't login as root as I try to create several databases and
users.
docker-compose.yml
mariadb:
image: mariadb:latest
restart: always
mem_limit: 128m
container_name: mariadb
environment:
MYSQL_ROOT_PASSWORD: xxx
TERM: xterm
volumes:
- ./volumes/var/lib/mysql:/var/lib/mysql
- ./volumes/etc/mysql/conf.d:/etc/mysql/conf.d
# --skip-name-resolve
# avoids: ""[Warning] IP address '172.17.0.60' could not be resolved: Name or service not known""
command: mysqld --skip-name-resolve
Results:
$ docker-compose up -d
Creating mariadb
$ docker run -it --link mariadb:mysql --rm mariadb sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'
ERROR 1045 (28000): Access denied for user 'root'@'172.17.0.3' (using password: YES)
I also tried a minimal run with an other error:
$ docker pull mariadb
Using default tag: latest
latest: Pulling from library/mariadb
8b87079b7a06: Pull complete
a3ed95caeb02: Pull complete
8b31a672b2e4: Pull complete
f959b6b404b6: Pull complete
9474f626fd77: Pull complete
8b9beff43c30: Pull complete
bac5b85f382e: Pull complete
b5afe408f722: Pull complete
336a899336bf: Pull complete
1f35fa63a903: Pull complete
4c9af553aed4: Pull complete
65beec678ddf: Pull complete
c9b983c9f92d: Pull complete
Digest: sha256:a609827ea58e9b719a1265694d8eee7baa5d556b78e53073d0199081b6884d1f
Status: Downloaded newer image for mariadb:latest
$ docker run --name some-mariadb -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mariadb
ea0a9cc7a3adde1d06af772fa5e08b4566e0f3e620c4df5e0aaeaeeed8e85b0e
$ docker run -it --link some-mariadb:mysql --rm mariadb sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'
ERROR 2003 (HY000): Can't connect to MySQL server on '172.17.0.2' (111 "Connection refused")
Any suggestions?
Did you start the database multiple times with different root passwords? The password is only set when the database directory is initialized (ie on first startup). If you don't have any data, you can blow away ./volumes/var/lib/mysql and start it again to use the password specified. As for creating users and databases, have you looked at the docs for /docker-entrypoint-initdb.d/ directory? You can drop an sql or sh file in there and they will be used on the first startup.
You were right.. I had old data in the volume. After deleting it it worked.
Thanks for the hint with the sql file too!
Most helpful comment
Did you start the database multiple times with different root passwords? The password is only set when the database directory is initialized (ie on first startup). If you don't have any data, you can blow away
./volumes/var/lib/mysqland start it again to use the password specified. As for creating users and databases, have you looked at the docs for/docker-entrypoint-initdb.d/directory? You can drop ansqlorshfile in there and they will be used on the first startup.