# Database is readonly. How to correct permissions?

**URL:** <https://forums.plex.tv/t/database-is-readonly-how-to-correct-permissions/674225>\
**Category:** Plex Media Server\
**Tags:** server-linux\
**Created:** [January 4, 2021, 1:11pm UTC](https://forums.plex.tv/t/database-is-readonly-how-to-correct-permissions/674225 "2021-01-04T13:11:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jon\_jones](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@jon\_jones](https://forums.plex.tv/u/jon_jones)\
**Post date:** [January 4, 2021, 1:11pm UTC](https://forums.plex.tv/t/database-is-readonly-how-to-correct-permissions/674225/1 "2021-01-04T13:11:55Z")

</div>

Hi,

I was having some problems with the ‘Recommended’ tab not loading so I ran the database fix from this guide [here](https://support.plex.tv/articles/201100678-repair-a-corrupt-database/).

Since the repair Plex is not able to start due to a readonly database.

The db file is set with plex:plex as the owner and I’ve tried a few different permissions including 777.

What are the correct permissions for the database file?

Cheers,  
Jon

```auto
Jan 04, 2021 12:22:21.333 [0x7fb3a7f69700] INFO - Processor Intel(R) Core(TM) i7-6700T CPU @ 2.80GHz
Jan 04, 2021 12:22:21.333 [0x7fb3a7f69700] INFO - ./Plex Media Server
Jan 04, 2021 12:22:21.333 [0x7fb3b0efd780] DEBUG - BPQ: [Idle] -> [Starting]
Jan 04, 2021 12:22:21.334 [0x7fb3b0efd780] ERROR - Unable to open named mutex 9334581e-7251-4ef7-a8ec-5bfe8e89ff68 with option 1: Permission denied
Jan 04, 2021 12:22:21.334 [0x7fb3b0efd780] DEBUG - FeatureManager: Using cached data for features list
Jan 04, 2021 12:22:21.334 [0x7fb3b0efd780] DEBUG - Opening 20 database sessions to library (com.plexapp.plugins.library), SQLite 3.26.0, threadsafe=1
Jan 04, 2021 12:22:21.336 [0x7fb3b0efd780] ERROR - SQLITE3:(nil), 14, cannot open file at line 38389 of [bf8c1b2b7a]
Jan 04, 2021 12:22:21.336 [0x7fb3b0efd780] ERROR - SQLITE3:(nil), 14, os_unix.c:38389: (2) open(/var/snap/plexmediaserver/common/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db-journal) - No such file or directory
Jan 04, 2021 12:22:21.336 [0x7fb3b0efd780] ERROR - SQLITE3:(nil), 1544, statement aborts at 1: [PRAGMA journal_mode=WAL] attempt to write a readonly database
Jan 04, 2021 12:22:21.336 [0x7fb3b0efd780] ERROR - Database corruption: sqlite3_statement_backend::loadOne: attempt to write a readonly database

```

Server Version#: 1.21.1

---

<div class="post-metadata">

**Author:** ![OttoKerner](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/ottokerner/32/10079_2.png) [@OttoKerner](https://forums.plex.tv/u/OttoKerner)\
**Post date:** [January 4, 2021, 1:15pm UTC](https://forums.plex.tv/t/database-is-readonly-how-to-correct-permissions/674225/2 "2021-01-04T13:15:41Z")

</div>

When you perform the repair procedure, the access permissions and the “owner” of the file are set to the user account under which the repair procedure was performed.  
i.e. most likely it will be now `root`, instead of `plex`.

> **[Linux Permissions Guide | Plex Support](https://support.plex.tv/articles/200288596-linux-permissions-guide/)**
>
> Permissions on Plex Media Server This is a write up of how permissions on Linux systems affect Plex Media Server...

---

<div class="post-metadata">

**Author:** ![jon\_jones](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@jon\_jones](https://forums.plex.tv/u/jon_jones)\
**Post date:** [January 4, 2021, 1:21pm UTC](https://forums.plex.tv/t/database-is-readonly-how-to-correct-permissions/674225/3 "2021-01-04T13:21:01Z")

</div>

Thanks for the incredibly quick response there.

You were correct - the owner should be `root` and not `plex`. I had been playing around with various permissions so the following fixed the issue:

```auto
chown -R root:root Databases
chmod -R 644 Databases

```

Cheers,  
Jon

---

<div class="post-metadata">

**Author:** ![OttoKerner](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/ottokerner/32/10079_2.png) [@OttoKerner](https://forums.plex.tv/u/OttoKerner)\
**Post date:** [January 4, 2021, 1:24pm UTC](https://forums.plex.tv/t/database-is-readonly-how-to-correct-permissions/674225/4 "2021-01-04T13:24:55Z")

</div>

Actually, it should be the other way around. You should never run any app as the user `root`. By default, Plex is running as user account `plex`.  
(Unless you are using some special kind of Linux where this fundamental security priciple has been disabled. `root` is the “super user” which has full rights to do anything on your system. Which means that if any app which is running as `root` has a bug or a security flaw which makes it susceptible to hacking, the consequences can be disastrous.)

---

<div class="post-metadata">

**Author:** ![jon\_jones](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@jon\_jones](https://forums.plex.tv/u/jon_jones)\
**Post date:** [January 4, 2021, 1:27pm UTC](https://forums.plex.tv/t/database-is-readonly-how-to-correct-permissions/674225/5 "2021-01-04T13:27:39Z")

</div>

That was my confusion with looking at documentation and not having much success.

My Plex is installed via snap (Ubuntu 20.04.1 LTS, no special modifications).

It wasn’t working with permissions set as `plex`, only `root` and I’ve always observed via `top` that all the Plex services run as `root`. I see what you mean - this probably isn’t a good idea.

---

<div class="post-metadata">

**Author:** ![OttoKerner](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/ottokerner/32/10079_2.png) [@OttoKerner](https://forums.plex.tv/u/OttoKerner)\
**Post date:** [January 4, 2021, 1:28pm UTC](https://forums.plex.tv/t/database-is-readonly-how-to-correct-permissions/674225/6 "2021-01-04T13:28:31Z")

</div>

I have no experience with Snap, so it might just be a quirk of this system.

---

<div class="post-metadata">

**Author:** ![jon\_jones](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@jon\_jones](https://forums.plex.tv/u/jon_jones)\
**Post date:** [January 4, 2021, 1:30pm UTC](https://forums.plex.tv/t/database-is-readonly-how-to-correct-permissions/674225/7 "2021-01-04T13:30:19Z")

</div>

Yeah I think it works pretty differently to the standard .deb install … which is how I wish I had installed it.

It’s also not installed as a standard service and needs to be restarted via `snap restart plexmediaserver`.

Definitely a few ‘quirks’.

---

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [January 4, 2021, 1:49pm UTC](https://forums.plex.tv/t/database-is-readonly-how-to-correct-permissions/674225/8 "2021-01-04T13:49:20Z")

</div>

SNAP packages all run as root, in their SNAP containers, per SNAP rules.

They are nothing like their native package counterparts.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [April 4, 2021, 1:49pm UTC](https://forums.plex.tv/t/database-is-readonly-how-to-correct-permissions/674225/9 "2021-04-04T13:49:27Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
