Your Plex database is a single SQLite file that stores everything about your server except the media files themselves — library metadata, watch history, user preferences, poster artwork links, play sessions, and server configuration. When it works, you never think about it. When it breaks, everything breaks: libraries won’t load, metadata disappears, the server crashes on startup, or performance degrades to the point where browsing your library takes 30 seconds per screen.

Here’s how to diagnose database problems, repair them, and keep them from coming back.

Signs Your Database Needs Attention

Where Plex Stores Its Database

The database file location depends on your OS:

The main file is com.plexapp.plugins.library.db. You may also see -wal and -shm companion files — these are SQLite’s write-ahead log and shared memory files. Don’t delete them while Plex is running.

Built-In Repair Tools

Plex has four maintenance operations accessible from Settings → Troubleshooting (or Manage → Troubleshooting in newer versions):

  1. Repair Database: Runs SQLite integrity checks and attempts to fix minor corruption. This is the first thing to try and fixes most issues.
  2. Clean Bundles: Removes orphaned metadata bundles — artwork and data for items that no longer exist in your library. Reclaims disk space.
  3. Optimize Database: Runs SQLite VACUUM and REINDEX, compacting the database file and rebuilding indexes for faster queries. Can dramatically improve browsing speed on bloated databases.
  4. Empty Trash: Permanently removes items you’ve deleted from libraries. Until you empty trash, deleted items still exist in the database.

Run them in this order: Repair → Empty Trash → Clean Bundles → Optimize. Wait for each to complete before starting the next. On large libraries (50K+ items), Optimize can take 30–60 minutes.

Manual SQLite Repair

When Plex’s built-in repair fails — usually when the database is too corrupted for Plex to even start — you can repair it manually with the sqlite3 command-line tool.

Step 1: Stop Plex completely

The database must not be in use. Stop the Plex service, verify no Plex Media Server process is running.

Step 2: Back up the current database

Copy com.plexapp.plugins.library.db, .db-wal, and .db-shm to a safe location. If the repair makes things worse, you want to be able to revert.

Step 3: Check integrity

sqlite3 com.plexapp.plugins.library.db "PRAGMA integrity_check;"

If this returns “ok”, the database isn’t structurally corrupted — the problem is elsewhere. If it returns errors, proceed to the dump-and-reimport method.

Step 4: Dump and reimport

sqlite3 com.plexapp.plugins.library.db ".dump" | sqlite3 repaired.db

This exports all recoverable data to SQL, then imports it into a fresh database. Corrupted rows are skipped. Rename repaired.db to com.plexapp.plugins.library.db and start Plex.

You may lose some data — the rows that were corrupted. Usually this means a few items lose their metadata or watch status, which Plex repopulates on the next library scan.

Optimization for Large Libraries

Libraries with 100K+ items (heavy TV show collections) put real strain on SQLite. Some tips:

Preventing Corruption

When to Rebuild From Scratch

If the database is so corrupted that dump-and-reimport fails, or if the repaired database is still behaving erratically, sometimes the fastest fix is to delete the database entirely and let Plex rebuild from scratch. You’ll lose all watch history, custom metadata edits, and user preferences — but the library structure rebuilds automatically from your files.

Before rebuilding: export watch history from Tautulli (if you have it), note any custom metadata or collection setups you’ll need to recreate, and ensure your media files are properly named so the rescan matches everything correctly.

Database giving you trouble?

Our techs repair corrupted Plex databases, recover watch history, and optimize server performance. Flat rate, no fix no charge.

Book a Fix →