MySQL/Upgrading

When updating to a new version, Kodi will make a copy of the current DB and upgrade the copy. That way if anything goes wrong in the upgrading you still have an original untouched copy of your DB.

Backing up the database
BACKUP YOUR DATABASE JUST IN CASE.

Even though Kodi makes a copy of your DB and updates that, it is still highly recommended to export your library from your current version before beginning the upgrade process. You don't want to find yourself starting your library from scratch, and it's better to be safe than sorry.

It's also a good idea to make periodic backups of your library even if you are not updating Kodi. Disks can fail, bugs can happen, and if you've put a lot of time in setting up your library then you should play it safe.

To backup simply export the library to a single file using Settings -> Videos -> Library -> Export library and select "multiple files". "Single file" also works, but "multiple files" is recommended as it is the most fail-safe method, especially for saving/resorting images. For more information see HOW-TO:Backup the library.

Making sure Kodi can update the library
For Kodi to update the library from a previous version, you may need to make changes to your MySQL server. The user made for the MySQL DB ("xbmc" in most guides) will need access to create new databases. If the user already has that access then you don't need to do anything. If not, you will have to use the following command on your MySQL server:



Or if using an old xbmc username:



If you are worried about security then you can limit Kodi's access in MySQL once it has created the new video DB. However, you will need to re-grant these privileges the next time you update Kodi. If the only thing you use MySQL for is Kodi then you don't really need to worry about security.

Upgrade fails

 * Method 1


 * 1) Downgrade Kodi on one of your Kodi devices to the previous version of Kodi (you only need to do this to one device).
 * 2) Quit Kodi
 * 3) Place between the ... tags, both true and true, in your advancedsettings.xml file on the downgraded Kodi device.
 * 4) Start Kodi
 * 5) Export the library using Settings -> Videos -> Library -> Export library and select "Separate Files per entry" to export to separate .nfo files next to your video files.
 * 6) Select "Export thumbnails and fanart" if you want to save/store such artwork too, next to your video files.
 * 7) Select "Overwrite old files" so video media details, watched status and/or resume points will be updated too.
 * 8) Let Kodi export the video library.
 * 9) Quit Kodi
 * 10) If you used the tag in your advancedsettings.xml file, remove these lines. Kodi will simply use default database names instead (MyVideos and MyMusic). Sometimes using the tag will cause issues when updating the MySQL libraries, but the tag is not needed as of Kodi v11 and later.
 * 11) Use the MySQL configuration utility to drop/delete the existing MySQL copies of the Kodi database(s).
 * 12) When using phpMyAdmin: select Databases option from the top of the screen, put a checkbox in front of all databases called MyMusic or MyVideos followed by some digits, and select Drop underneath the list. Confirm that you want to drop the databases.
 * 13) When using the command line tools: enter   including the semicolon. Type   for every name in the resulting list starting with MyMusic or MyVideos and followed by some digits, for example:   Note that actual names may vary per Kodi version, and do not forget the trailing semicolon.
 * 14) You can now re-update the device you downgraded in step 1.
 * 15) Import the library by simply scanning it in as a new file source. Kodi will pick up the exported data as it scans the files in.
 * 16) Kodi will now rebuild a fresh MySQL library DB, but using all your existing information.
 * 17) You can now open/launch Kodi on the other devices.


 * Method 2


 * 1) Quit Kodi
 * 2) Use the MySQL configuration utility to drop/delete the existing MySQL copies of the Kodi database(s).
 * 3) Consult the table on Databases/Versions and note the version number for the downgraded version. You will want to get rid of all of the versions after that version.
 * 4) When using phpMyAdmin: select Databases option from the top of the screen, put a checkbox in front of all databases (after the stable version from step 2) called MyMusic or MyVideos followed by some digits, and select Drop underneath the list. Confirm that you want to drop the databases.
 * 5) When using the command line tools: enter   including the semicolon. Type   for every name in the resulting list, after the stable version from step 2, starting with MyMusic or MyVideos and followed by some digits, for example:   Note that actual names may vary per Kodi version, and do not forget the trailing semicolon.
 * 6) Start one Kodi instance that is using the version you want to use and give it lots of time to update the database.
 * 7) Kodi will make a new updated DB using the last working DB from the previous Kodi installation.
 * 8) You can now open/launch Kodi on the other devices.

Different Kodi versions
Using MySQL to sync the library only works if all Kodi devices are using the same version of Kodi.