Migrating mysql into a docker. KODI Supported!

Leave a comment

May 12, 2020 by aubreykloppers

This is actually quite an easy one.

What you have to do is first off create a backup of your mysql database:

root@host:~# mysqldump -u root -pSECRET --all-databases > all_databases.sql

Then, you have to create a mysql docker:

root@host:~# docker run --restart always --name mysql --network=host -e \
MYSQL_ROOT_PASSWORD=SECRET -d mariadb:latest

Now, presumably you are doing this for KODI, you have to create the user PRIOR to loading the database file:

root@host:~# docker exec -ti mysql mysql -uroot -p
MariaDB [(none)]> CREATE USER 'kodi' IDENTIFIED BY 'kodi';
MariaDB [(none)]> GRANT ALL ON *.* TO 'kodi';
MariaDB [(none)]> flush privileges;

Then restore the database into the docker:

root@host:~# docker exec -i mysql mysql -uroot -pSECRET < all_databases.sql

You can now kill your original instance of mysql (native) and continue using the docker-based mysql.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: