Access Mysql from docker container and export the database
To access the database, first we need to enter into the container. Below is the command:
Following command will show list of docker containers
docker ps
We have found that the container (container_name) has the sql database hosted. Below is the query to access the container
docker exec -it container_name bash
Once we enter into bash, use following command to access with root permission
mysql -u username -p password
To Export database below is the command for the same:
docker exec container_name /usr/bin/mysqldump --single-transaction -uusername --password=password databasename> backup.sql
Comments
Post a Comment