Difference between revisions of "MySQL/Upgrading"

From Official Kodi Wiki
Jump to navigation Jump to search
 
(29 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{:MySQL/Contents}}
{{mininav| [[MySQL]] }}
{{mininav| [[MySQL]] }}
When updating to a new version, XBMC 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.


{{warning|MariaDB 10.1.11 users might want to avoid upgrading to Kodi v16 until they have updated MairaDB to 10.1.12.}}
{{:MySQL/Contents}}


Starting in XBMC v12 "Frodo", you no longer need to use [[path substitution]] to sync thumbnails and other art between XBMC devices. Using path subs is still supported, which is useful for XBMC devices with small amounts of memory.
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.




{{big|{{note|Updating your library may take a few minutes, so be sure to give XBMC time to do its thing. Stopping midway will mess up the updated DB. }} }}
{{big|{{note|Updating your library may take a few minutes, so be sure to give Kodi time to do its thing. Stopping midway will mess up the updated DB. }} }}




Line 13: Line 13:
{{big|'''BACKUP YOUR DATABASE JUST IN CASE.'''}}
{{big|'''BACKUP YOUR DATABASE JUST IN CASE.'''}}


Even though XBMC makes a copy of your DB and updates that, it is still highly recommended to [[Import - Export Video Library#Import .2F Export options|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.
Even though Kodi makes a copy of your DB and updates that, it is still highly recommended to '''''[[Import-export_library|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 XBMC. 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.
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 {{highlight|[[Settings/Videos#Library|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.
To backup simply '''''[[Import-export_library|export]]''''' the library using {{highlight|bordered=yes|[[Settings/Media/Library|Settings -> Media -> Library]]}}. Be aware of the differences between Single File and Separate File exports. For more information see '''[[Backup]]'''.


==Making sure MySQL can update the library==
==Making sure Kodi can update the library==
'''Note:''' If you originally set up MySQL using this XBMC Wiki guide then you should not have to worry about this section. It never hurts to double check the settings, though.
{{Note|If you originally set up MySQL using this Kodi Wiki guide then you should not have to worry about this section. It never hurts to double check the settings, though.}}




For XBMC 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:
{{Note|if you used 'xbmc' as a username in the past, you can keep using it even though the program has changed names to Kodi. It makes no difference as long as that is the name you set up MySQL with.}}


:<code>GRANT ALL ON *.* TO 'xbmc';</code>
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:


<syntaxhighlight lang="sql" inline>GRANT ALL ON *.* TO 'kodi';</syntaxhighlight>


If you are worried about security then you can limit XBMC'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 XBMC. If the only thing you use MySQL for is XBMC then you don't really need to worry about security.


==Thumbnails==
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.
{{note|This only applies for upgrading from XBMC v11 to XBMC v12.}}
===If you used Path Substitution===
XBMC v12 and later no longer needs path substitution for syncing thumbnails.


==Common problems==
===Upgrade fails===
;Method 1


{{bluev|'''NOTICE:'''|'''You can still use path substitution if you want to!''' Path subs are still useful for devices with low memory, like the Apple TV2 and various devices using small USB drives or SSDs. If you still want to use path subs then skip this entire "Thumbnails" section. Loading the library will be slowing with path subs, but this might be a reasonable trade-off for your situation.}}
# Downgrade Kodi on one of your Kodi devices to the previous version of Kodi (you only need to do this to one device).
 
# Quit Kodi
 
# Place between the {{highlight|<nowiki><videolibrary>...</videolibrary></nowiki>}} tags, both {{highlight|<nowiki><importwatchedstate>true</importwatchedstate></nowiki>}} and {{highlight|<nowiki><importresumepoint>true</importresumepoint></nowiki>}}, in your [[advancedsettings.xml]] file on the downgraded Kodi device.
;If you used path subs for the entire Thumbnails folder - ''Extra safe method''<ref name="extra safe method">The extra safe part is because we copy the thumbnails artwork manually to each XBMC device, instead of having XBMC just download the art from the internet. If you have library items that scanned their art in a long time ago then the internet copy might not exist anymore, hence this extra safe method.</ref>
# Start Kodi
# Quit all XBMC devices.
# '''''[[Import-export_library|Export]]''''' the libraries using {{highlight|bordered=yes|[[Settings/Media/Library|Settings -> Media -> Library]]}} and select "Separate Files per entry" to export to separate .nfo files next to your video files.
# Update all instances to XBMC v12 "Frodo", but don't open/launch XBMC yet.
# Select "Export thumbnails and fanart" if you want to save/store such artwork too, next to your video files.
# Choose one XBMC device and open XBMC
# Select "Overwrite old files" so video media details, watched status and/or resume points will be updated too.
# Say yes when it asks to update art.
# Let Kodi export the video library.
# Copy your path-substituted thumbnails folder onto all XBMC devices, replacing the local thumbnails folder in the [[userdata]] folder.
# Quit Kodi
# On the first XBMC device go into {{highlight|userdata/database/}} and copy the "Textures13.db" file to all the other XBMC devices in their {{highlight|userdata/database/}} folders.
# If you used the <name> tag in your [[advancedsettings.xml]] file, remove these lines. Kodi will simply use default database names instead (MyVideos and MyMusic). Sometimes using the <name> tag will cause issues when updating the MySQL libraries, but the tag is not needed as of Kodi v11 and later.
# Remove path substitution for thumbnails from the [[advancedsettings.xml]] file of each XBMC device.
# Use the MySQL configuration utility to drop/delete the existing MySQL copies of the Kodi database(s).
# You can now open/launch XBMC on your other devices.
## 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.
# From that point on, XBMC will sync art/thumbs directly to each XBMC box, but will keep them in sync (whereas before XBMC would only add art on one box, and boxes could have different artwork if set manually). Having the thumbnails folder locally on each box will also speed up loading the library, and what art to use is stored in the videos DB that MySQL is already sharing.
## When using the command line tools: enter <code>show databases;</code> including the semicolon. Type <code>drop database <name>;</code> for every name in the resulting list starting with '''MyMusic''' or '''MyVideos''' and followed by some digits, for example: <code>drop database MyVideos78; drop database MyMusic46;</code> Note that actual names may vary per Kodi version, and do not forget the trailing semicolon.
 
# You can now re-update the device you downgraded in step 1.
 
# 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.
;If you used path subs for only userdata/thumbnails/videos/ and userdata/thumbnails/music/ - ''Extra safe method''<ref name="extra safe method" />
# Kodi will now rebuild a fresh MySQL library DB, but using all your existing information.
# Quit all XBMC devices.
# You can now open/launch Kodi on the other devices.
# Choose one XBMC device to do the initial thumbnails update.
# Copy the path-substituted thumbnails folder(s) for {{highlight|userdata/thumbnails/videos/}} and/or {{highlight|userdata/thumbnails/music/}} to the local {{highlight|[[userdata]]/thumbnails/}} folder on your first XBMC device.
#:''If your thumbnails folders are being shared from another XBMC device's thumbnails folder then you don't need to do this. Just make that XBMC device your "first device" for these instructions.''
# Update all instances to XBMC v12 "Frodo", but don't open/launch XBMC yet.
# Open XBMC on your first device.
# Say yes when it asks to update art.
# Copy your the thumbnails folder from the first XBMC device onto all the other XBMC devices.
# On the first XBMC device go into {{highlight|userdata/database/}} and copy the "Textures13.db" file to all the other XBMC devices in their {{highlight|userdata/database/}} folders.
# Remove path substitution for thumbnails from the [[advancedsettings.xml]] file of each XBMC device.
# You can now open/launch XBMC on your other devices.
# From that point on, XBMC will sync art/thumbs directly to each XBMC box, but will keep them in sync (whereas before XBMC would only add art on one box, and boxes could have different artwork if set manually). Having the thumbnails folder locally on each box will also speed up loading the library, and what art to use is stored in the videos DB that MySQL is already sharing.


===If you copied your thumbnails folder===
If you simply copied your thumbnails folder between XBMC devices then you technically don't have to do anything extra. However, you may wish to use this extra safe method:<ref name="extra safe method" />
# Quit all XBMC devices.
# Update all instances to XBMC v12 "Frodo", but don't open/launch XBMC yet.
# Choose one XBMC device and open XBMC
# Say yes when it asks to update art.
# Copy your the thumbnails folder from the first XBMC device onto all the other XBMC devices.
# On the first XBMC device go into {{highlight|userdata/database/}} and copy the "Textures13.db" file to all the other XBMC devices in their {{highlight|userdata/database/}} folders.
# You can now open/launch XBMC on your other devices.


If you used some process to keep the individual thumbnail folders in sync (such as a script, Dropbox, symbolic links, or rsync) then you no longer need to use those processes. XBMC will download images for new library entries on each XBMC device, and will synchronize the download URL via MySQL (using the videos and/or music DB).
;Method 2


==Common problems==
# Quit Kodi
===Upgrade fails===
# Use the MySQL configuration utility to drop/delete the existing MySQL copies of the Kodi database(s).  
# Downgrade XBMC on one of your XBMC devices to the previous version of XBMC (you only need to do this to one device). [[Export]] the library to multiple files using {{highlight|[[Settings/Videos#Library|Settings -> Videos -> Library]] -> Export library}} and select "multiple files".
## Consult the table on '''[[Databases#Database_Versions]]''' and note the version number for the downgraded version. You will want to get rid of all of the versions '''after''' that version.
#:'''''Note:''' If you backed up your XBMC database, you can use that backup in place of this first step.''
## 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.
# Quit XBMC
## When using the command line tools: enter <code>show databases;</code> including the semicolon. Type <code>drop database <name>;</code> 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: <code>drop database MyVideos78; drop database MyMusic46;</code> Note that actual names may vary per Kodi version, and do not forget the trailing semicolon.
# Place {{highlight|<nowiki><importwatchedstate>true</importwatchedstate></nowiki>}} in your [[advancedsettings.xml]] file on the downgraded XBMC device.
# Start one Kodi instance that is using the version you want to use and give it lots of time to update the database.
# If you used the <name> tag in your [[advancedsettings.xml]] file, remove these lines. XBMC will simply use default database names instead (MyVideos and MyMusic). Sometimes using the <name> tag will cause issues when updating the MySQL libraries, but the tag is not needed as of XBMC v11.
# Kodi will make a new updated DB using the last working DB from the previous Kodi installation.
# Use the MySQL configuration utility to drop/delete the existing MySQL copies of the XBMC database(s).  
# You can now open/launch Kodi on the other devices.
## 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.
## When using the command line tools: enter <code>show databases;</code> including the semicolon. Type <code>drop database <name>;</code> for every name in the resulting list starting with '''MyMusic''' or '''MyVideos''' and followed by some digits, for example: <code>drop database MyVideos75; drop database MyMusic32;</code> Note that actual names may vary per XBMC version, and do not forget the trailing semicolon.
# Upgrade the downgraded XBMC device back up to v12 and open XBMC again.
# Import the library by simply scanning it in as a new file source. XBMC will pick up the exported data as it scans the files in.
# XBMC will now rebuild a fresh MySQL library DB, but using all your existing information.
# You can now open/launch XBMC on the other devices.


===Different XBMC versions===
===Different Kodi versions===
Using MySQL to sync the library only works if all XBMC devices are using the same version of XBMC.
Using MySQL/MariaDB to sync the video and/or music library only works when all connected Kodi devices are using the same major version of the Kodi application.


==Notes==
==Notes==
<references />
<references />


{{Frodo updated}}
{{Isengard updated}}

Latest revision as of 05:06, 23 January 2022

Home icon grey.png   ▶ MySQL ▶ Upgrading
Stop hand.png MariaDB 10.1.11 users might want to avoid upgrading to Kodi v16 until they have updated MairaDB to 10.1.12.

Share libraries w/MySQL, guide:

  1. Introduction
  2. Setting up MySQL
  3. Setting up Kodi

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.


Note: Updating your library may take a few minutes, so be sure to give Kodi time to do its thing. Stopping midway will mess up the updated DB.


1 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 using Settings -> Media -> Library. Be aware of the differences between Single File and Separate File exports. For more information see Backup.

2 Making sure Kodi can update the library

Note: If you originally set up MySQL using this Kodi Wiki guide then you should not have to worry about this section. It never hurts to double check the settings, though.


Note: if you used 'xbmc' as a username in the past, you can keep using it even though the program has changed names to Kodi. It makes no difference as long as that is the name you set up MySQL with.

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:

GRANT ALL ON *.* TO 'kodi';


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.

3 Common problems

3.1 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 <videolibrary>...</videolibrary> tags, both <importwatchedstate>true</importwatchedstate> and <importresumepoint>true</importresumepoint>, in your advancedsettings.xml file on the downgraded Kodi device.
  4. Start Kodi
  5. Export the libraries using Settings -> Media -> 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 <name> tag in your advancedsettings.xml file, remove these lines. Kodi will simply use default database names instead (MyVideos and MyMusic). Sometimes using the <name> 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).
    1. 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.
    2. When using the command line tools: enter show databases; including the semicolon. Type drop database <name>; for every name in the resulting list starting with MyMusic or MyVideos and followed by some digits, for example: drop database MyVideos78; drop database MyMusic46; Note that actual names may vary per Kodi version, and do not forget the trailing semicolon.
  12. You can now re-update the device you downgraded in step 1.
  13. 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.
  14. Kodi will now rebuild a fresh MySQL library DB, but using all your existing information.
  15. 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).
    1. Consult the table on Databases#Database_Versions and note the version number for the downgraded version. You will want to get rid of all of the versions after that version.
    2. 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.
    3. When using the command line tools: enter show databases; including the semicolon. Type drop database <name>; 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: drop database MyVideos78; drop database MyMusic46; Note that actual names may vary per Kodi version, and do not forget the trailing semicolon.
  3. Start one Kodi instance that is using the version you want to use and give it lots of time to update the database.
  4. Kodi will make a new updated DB using the last working DB from the previous Kodi installation.
  5. You can now open/launch Kodi on the other devices.

3.2 Different Kodi versions

Using MySQL/MariaDB to sync the video and/or music library only works when all connected Kodi devices are using the same major version of the Kodi application.

4 Notes