Plex Error: Unable to set up server: std::exception (N2DB9ExceptionE)
好的,我现在需要帮用户总结一篇文章的内容,控制在100字以内,而且不需要特定的开头。首先,我得仔细阅读文章,理解主要信息。 文章讲的是Plex服务器在Unraid上崩溃了,作者尝试了手动修复数据库但失败了,最后通过恢复备份解决了问题。还提到了如何设置定期备份的重要性。 接下来,我要提炼关键点:Plex崩溃、数据库损坏、手动修复无效、恢复备份成功、建议启用备份。 然后,把这些点用简洁的中文表达出来,确保不超过100字。可能需要调整句子结构,使其流畅且信息完整。 最后,检查一下是否符合用户的要求,没有使用特定的开头词,并且内容准确。 </think> 文章描述了作者在Unraid上运行的Plex服务器因数据库损坏而崩溃的经历。经过手动修复尝试失败后,作者通过恢复Plex的定期备份成功解决问题,并强调启用数据库备份的重要性。 2026-3-25 16:40:49 Author: www.blackmoreops.com(查看原文) 阅读量:2 收藏

My Plex server on Unraid went down hard this week. No warning, no gradual degradation — just stopped working. After a few restarts produced the same result, I dug into the logs and found this:

Starting Plex Media Server.
Error: Unable to set up server: std::exception (N2DB9ExceptionE)
Stopping Plex Media Server

Classic corrupted database. Here’s how I fixed it, what I tried first, and why a simple backup restore ended up being the answer.

Screenshot of terminal showing "PRAGMA integrity_check" returning "ok" after restoring the Plex database backup on Unraid

Screenshot of terminal showing “PRAGMA integrity_check” returning “ok” after restoring the Plex database backup on Unraid

First Attempt: Manual Database Repair

The official Plex documentation isn’t great for Docker setups on Unraid. The repair process requires SQLite — which is bundled with Plex — but you need Plex stopped while running the commands. That means using the container’s console rather than running things from the Unraid terminal.

Stop the Plex Service Inside the Container

In Unraid, go to Docker, click the Plex container icon, and open the console.

For the older plexinc/pms-docker container:

./plex_service.sh -d

For the newer lscr.io/linuxserver/plex container:

cd /var/run/s6-rc/servicedirs/
s6-svc -d svc-plex

Navigate to the Database Directory

cd "/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases/"

Back Up Before Touching Anything

cp com.plexapp.plugins.library.db com.plexapp.plugins.library.db.bak

Don’t skip this. Even if the database is corrupted, keep the original.

Run an Integrity Check

"/usr/lib/plexmediaserver/Plex Media Server" --sqlite com.plexapp.plugins.library.db "PRAGMA integrity_check"

If this returns anything other than ok, the database has errors.

Attempt a Quick Recovery

"/usr/lib/plexmediaserver/Plex Media Server" --sqlite com.plexapp.plugins.library.db ".output recover.out" ".recover"

This tries to salvage data from a corrupted database. In my case, it wasn’t enough.


Second Attempt: Full Manual Dump and Rebuild

When the quick recovery doesn’t cut it, the next step is dumping the database contents and rebuilding from the dump.

Dump the Database

"/usr/lib/plexmediaserver/Plex Media Server" --sqlite com.plexapp.plugins.library.db .dump > dump.sql

Remove the Corrupted File

rm com.plexapp.plugins.library.db

Rebuild From the Dump

"/usr/lib/plexmediaserver/Plex Media Server" --sqlite com.plexapp.plugins.library.db < dump.sql

Fix File Ownership

For plexinc/pms-docker:

chown plex:plex com.plexapp.plugins.library.db

For lscr.io/linuxserver/plex:

chown abc:users com.plexapp.plugins.library.db

This also didn’t work. The rebuilt database came back as 0 bytes — the original was too far gone to recover anything useful from.

Terminal output of ls -ltrah in the Plex Databases directory on Unraid, showing dated backup files and the current database files

Terminal output of ls -ltrah in the Plex Databases directory on Unraid, showing dated backup files and the current database files

The Actual Fix: Restoring a Plex Database Backup

Here’s where the backup I’d set up months ago saved the day. Plex has a built-in scheduled backup — it’s buried in Settings > Scheduled Tasks and it’s off by default. I’d enabled it and set it to run every 3 days.

My database directory listed several clean backups:

-rw-r--r-- 1 plex users  81M Mar 18 03:16 com.plexapp.plugins.library.db-2026-03-18
-rw-r--r-- 1 plex users  81M Mar 21 02:06 com.plexapp.plugins.library.db-2026-03-21
-rw-r--r-- 1 plex users  81M Mar 24 02:06 com.plexapp.plugins.library.db-2026-03-24

I grabbed the most recent one and ran it through an integrity check first.

Restore the Backup

cp com.plexapp.plugins.library.db-2026-03-24 com.plexapp.plugins.library.db
chown plex:users com.plexapp.plugins.library.db

Verify It’s Clean

"/usr/lib/plexmediaserver/Plex Media Server" --sqlite com.plexapp.plugins.library.db "PRAGMA integrity_check"

Output:

ok

That’s it. Restarted Plex, it came straight up, library intact.

Enable Plex Database Backups Now

If you’re not already running scheduled backups, turn them on before you need them.

In Plex Web, go to Settings → Scheduled Tasks and enable Backup database every X days. Three days is a reasonable interval — enough history to roll back past corruption without eating too much storage. Each backup is a full copy of the database, so on an 80MB database that’s around 240MB of backup files at any given time. Cheap insurance.

The backups land in the same directory as the live database and are named with a datestamp, making it obvious which is which.

Plex Web UI screenshot of Settings > Scheduled Tasks with the database backup schedule enabled and set to every 3 days

Plex Web UI screenshot of Settings > Scheduled Tasks with the database backup schedule enabled and set to every 3 days

When Backups Aren’t an Option

If you’re in a situation where backups aren’t available and the manual repair steps above haven’t worked, there’s a community tool worth knowing about: DBRepair by ChuckPa. It’s a more thorough repair utility built specifically for Plex databases, and there’s an Unraid-specific Docker support thread on the Unraid forums. Useful for large, complex libraries shared across multiple users where a backup restore isn’t an option.

For most home setups though, a clean backup beats every repair tool available.

Plex Database Repair on Unraid: Summary

The manual SQLite repair process works in some cases, but if the database is badly corrupted, the dump will produce a 0-byte file and you’re stuck. The real lesson here is to have the backup in place before it’s needed.

Steps that fixed it for me:

  1. Confirmed the database was corrupted via the error log
  2. Attempted quick recovery and full dump-rebuild — neither worked
  3. Restored from a 1-day-old Plex scheduled backup
  4. Ran PRAGMA integrity_check to confirm the restored file was clean
  5. Restarted Plex — library came up fully intact

Enable database backups in Plex’s Scheduled Tasks. It’s free, it’s built-in, and it’s the only thing that will save you when a repair fails.

For more Docker and self-hosting guides on Unraid, check out the Unraid category on BlackmoreOps.


文章来源: https://www.blackmoreops.com/plex-unable-to-set-up-server-stdexception-n2db9exceptione/
如有侵权请联系:admin#unsafe.sh