Though rare, it is possible for your main Plex Media Server database to become corrupted. For instance, it might happen if the computer is turned off without first quitting Plex Media Server. In such a situation, you can attempt to repair the database.
Tip!: It's always a good idea make a backup copy of the database file before doing any work on it.
In many cases, you may also be able to restore a database copy that was backed up via the Scheduled Tasks feature.
First, make sure you quit/exit your Plex Media Server so that it is not running. The following commands are run in the Terminal application.
To see how badly corrupted the database might be:
sqlite3 ~/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db "PRAGMA integrity_check"
Even if the integrity check doesn't return errors, it can still sometimes help to try and repair the database. In order to try and "repair" the database, you can perform a dump followed by a restore to get it back to normal:
sqlite3 ~/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db .dump > dump.sql
mv ~/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db ~/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db.original
sqlite3 ~/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db < dump.sql
Prior to restarting your Server, you should also delete or backup and move elsewhere the following two files:
- ~/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db-shm
- ~/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db-wal
Otherwise, simply deleting that
com.plexapp.plugins.library.db database file and restarting the Plex Media Server will restore your server to a fresh install state. (i.e. You will lose your existing libraries and need to recreate them, but you won't be affecting your content itself.)
Windows and Linux
Unlike OS X, most Windows and Linux installs don't come with SQLite3 tools installed by default. However, you can install them yourself if you like:
Related Page: SQLite.org download page
Once the SQLite3 tools are installed, you would run commands similar to the ones above for OS X, but substitute the appropriate path used in your OS and Plex Media Server install. As before, make sure that you quit/exit the Plex Media Server so that it is no longer active before running any commands.
On Windows, the content is located inside of the user directory.
%LOCALAPPDATA%\Plex Media Server\Plug-in Support\Databases\com.plexapp.plugins.library.db
In general, the location for the various Linux versions of Plex Media Server will be found under:
$PLEX_HOME/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db