I want to run the init.sql file after mysql container has started completely. I am using the following docker compose file. It is saying no /var/initdb/init.sql file with the following compose file.
services:
mysqldb:
container_name: mysql
image: mysql
restart: always
ports:
- "3306:3306"
volumes:
- /mysql-schema :/var/schema
- /init :/var/initdb
command: sh -c "mysql -u root < /var/initdb/init.sql"
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_USER=a12nserver
- MYSQL_PASSWORD=password
- MYSQL_DATABASE=a12nserver
networks:
- MY_network
If I use the command: sh -c "mysql -u root -p < /var/initdb/init.sql"
it gives me an error error: access denied
since password has not been entered. I want to run the init.sql file/files after the mysql container has completely started.