Last updated on November 3, 2021

A guide regarding the Plex database, useful if you want to do a clean install or move Plex to a new server or if you are experiencing issues.

Backup settings (watched status, ratings and so on)

  1. Shut down Plex Media Server so that it is not running.
  2. Go to File Explorer and find the hard drive that your Plex database is stored on.
  3. Right click on the hard drive and click on Properties.
  4. Click on the tab named Tools.
  5. In the error checking box click on the Check-button.
  6. If Windows find something wrong, just follow the instructions and Windows will fix it.
  7. Open a Command Prompt window and go the drive and location where your Plex database is located. Example, if your database is stored on drive N:\ and you have a folder named Plex, then the command you type would look like this
cd "N:\Plex\Plex Media Server\Plug-in Support\Databases"

or if you haven’t changed the path and it’s stored in the default location you just do this

cd "%LOCALAPPDATA%\Plex Media Server\Plug-in Support\Databases"
  1. First we’ll make a copy of your database just in case.
copy com.plexapp.plugins.library.db com.plexapp.plugins.library.db.original

Locating the Plex SQLite tool

The Plex SQLite tool is located alongside the Plex Media Server executable. You can find it in the following locations, depending on the operating system your server runs on. When the commands below reference "Plex SQLite", fill in the path listed here:

  • Windows (32-bit)"C:\Program Files (x86)\Plex\Plex Media Server\Plex SQLite.exe"
  • macOS"/Applications/Plex Media Server.app/Contents/MacOS/Plex SQLite"
  • Linux (desktop)"/usr/lib/plexmediaserver/Plex SQLite"
  • QNAP"/share/CACHEDEV1_DATA/.qpkg/PlexMediaServer/Plex SQLite"
  • Synology (DSM 6)"/var/packages/Plex Media Server/target/Plex SQLite"
  • Synology (DSM 7)"/var/packages/PlexMediaServer/target/Plex SQLite"
  1. Check if your database have corruption. (change the file path if you do not have Plex installed with default path)
"C:\Program Files (x86)\Plex\Plex Media Server\Plex SQLite.exe" com.plexapp.plugins.library.db "PRAGMA integrity_check"
  1. Even if the integrity check doesn’t return errors, it can still sometimes help to try and repair the database. With the Plex SQLite interpreter, you can easily attempt a repair with 1 command. The following command will attempt an automatic repair and store the result in a file named recover.out.
"C:\Program Files (x86)\Plex\Plex Media Server\Plex SQLite.exe" com.plexapp.plugins.library.db ".output recover.out" ".recover"

The above command will reassemble your database with all the valid data it can find in your file.

  1. Restart your computer and see if this solved the problem. If the problem persist after this then I’m sorry to tell you that you’ll need to do a completely fresh install of Plex Media Server and a completely new database, so continue to next step.
  2. First shut down Plex Media Server so that it is not running.
  3. Open a Command Prompt window and go the drive and location where your Plex database is located. Example, if your database is stored on drive N:\ and you have a folder named Plex, then the command you type would look like this
cd "N:\Plex\Plex Media Server\Plug-in Support\Databases"

or if you haven’t changed the path and it’s stored in the default location you just do this

cd "%LOCALAPPDATA%\Plex Media Server\Plug-in Support\Databases"

Just like you did before in step 7.

  1. Now we’re going to backup your settings, watched/unwatched, view progress, and ratings into a file named settings.sql
"C:\Program Files (x86)\Plex\Plex Media Server\Plex SQLite.exe" com.plexapp.plugins.library.db

The command line should now start with sqlite>

.output settings.sql
.dump metadata_item_settings

And hit enter. When it’s finished you will see sqlite> again. Then click CTRL + C.
15. If you copy the path you’re seeing in Command Prompt and open that one up in a File Explorer window you should now see a file named settings.sql there.
16. Copy or move this file somewhere safe. You have now backed up your settings.

If you are moving Plex to a new server and want to import your settings again first make sure that Plex Media Server is not running. Copy settings.sql into the Plex Media Server/Plug-in Support/Databases/ folder. From the Command Prompt terminal in that folder you run the following code

"C:\Program Files (x86)\Plex\Plex Media Server\Plex SQLite.exe" com.plexapp.plugins.library.db

And to insert your settings simply type the following:

.read settings.sql

Don’t be alarmed if you see errors with UNIQUE constraint failed: metadata_item_settings.id. This will be fixed in the next step.

First check how many duplicates there is by typing the following:

SELECT COUNT(*) FROM metadata_item_settings
WHERE id in (SELECT MIN(id) 
FROM metadata_item_settings 
GROUP BY guid HAVING COUNT(guid) > 1);

Then to remove the duplicates you have to run the following code:

DELETE FROM metadata_item_settings
WHERE id in (SELECT MIN(id) 
FROM metadata_item_settings 
GROUP BY guid HAVING COUNT(guid) > 1);

Sometimes the Plex SQLite won’t delete all at once which means you will have to run this code several times. To check how many you have left run the count SQL again. Then continue running the delete SQL until you reach 0.

After this you can start up your Plex Media Server again and you should have all your settings.

Perform a clean install of Plex to fix errors

Before you start on this make sure that you have followed the steps above first to backup your settings.

1. Uninstall Plex Media Server from your computer.
2. Delete the folder named Plex Media Server. This will delete your entire database and everything it has stored like posters, thumbnails and so on.
3. Install the latest Plex Media Server version. Do not launch Plex Media Server after install if you want the database stored on a different hard drive than the default (default is C:). If you want to store the database on a different drive then follow this guide
4. Launch Plex and add your libraries. Let it finish with scanning and adding media. For huge databases this will take a while, so go and do something else and continue when Plex Media Server is done.
5. When Plex Media Server is done with all your libraries, shut it down.
6. Now it’s time to copy settings.sql back into the Plex Media Server/Plug-in Support/Databases/ folder. From the Command Prompt terminal in that folder you run the following code

"C:\Program Files (x86)\Plex\Plex Media Server\Plex SQLite.exe" com.plexapp.plugins.library.db

And to insert your settings the following:

.read settings.sql

7. Start Plex Media Server back up again. Your settings, watched status and so on should now be back and everything is now working again. You are now using the latest and smarter database which Plex added in 2021.