Migrating mysql into a docker. KODI Supported!
Leave a commentMay 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.