MySQL Backups from localhost to running DB on Docker

Scenario: Apache running locally and database running on Docker.

Purpose: we need to restore a database into our database container.

Follow the next steps to copy the database restore file to the Docker machine, so we can restore the database from file:

From local

$ sudo docker cp db.sql.gz mysql56server:/db.sql.gz

Connect

$ sudo docker exec -it mysql56server /bin/bash

check

$ ls

perform import

$ zcat db.sql.gz | mysql -u root -p db

reference: https://docs.docker.com/engine/reference/commandline/cp/

TROUBLESHOOTIING

[Warning] World-writable config file ‘/etc/(…)/my.cnf’ is ignored

I got with it while trying to restore a considered size mysql file backup, so into /mysql/my.conf I added:

max_allowed_packet=1000M

and changed permissions to /mysql/my.conf file:

$ chmod 0444 my.cnf

and re-run the container

The size of BLOB/TEXT data inserted in one transaction is greater than 10% of redo log size. Increase the redo log size using innodb_log_file_size.

I got with it while trying to restore a considered size mysql file backup, so into /mysql/my.conf I added:

innodb_log_file_size=100M

and changed permissions to /mysql/my.conf file if you didn’t before:

$ chmod 0444 my.cnf

and re-run the container

The final my.cnf file looks like:

[mysqld]
general_log = 1
general_log_file = /var/lib/mysql/general.log

max_allowed_packet=1000M
innodb_log_file_size=100MB