I got a problem with mysql:5.7 with Docker. I know there are many questions about this but I just can't get this to work.
I simply want to create a mysql:5.7 container with docker-compose with the following settings on STARTUP!!:
- Create user "root" with password "mypw"
- Allow access with root user from ALL hosts and containers
- Create a table named "mytable"
My yml:
db:
build: "."
command:
- "--default-authentication-plugin=mysql_native_password"
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD="mypw"
volumes:
- "./mysql/database:/var/lib/mysql"
What i tried:
- Dockerfile: COPY ./mysqld.cnf /etc/mysql/mysql.conf.d/mysqld.cnf
- mysqld.cnf contains the line "bind-address = 0.0.0.0" at the end
- Add script to /docker-entrypoint-initdb.d/ with content "CREATE DATABASE mydb;"
- MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE variables (can't connect either)
- use skip-grant-tables in mysqld.cnf (errors)
- MYSQL_ROOT_HOST="%"
I just don't get why especially allow access from everywhere is so hard to do.
Can anyone please help with where to put what?
Thanks