Linux: MySql Docker Container – Export database

# Set Variables
sqlContainer="mysql-server"
userName=brucelee
password=chucknorris
databaseName=kimconnect


# Run mysql inside container
docker exec -it  $sqlContainer mysql -u$userName --password='$password'
show databases;

# Execute mysqldump
docker exec $sqlContainer /usr/bin/mysqldump -u$userName --password='$password' $databaseName | gzip > /var/tmp/$databaseName.sql.gz

Leave a Reply

Your email address will not be published. Required fields are marked *