EazyC
EazyC

Reputation: 819

Django on CentOS/Bluehost: Attempt to Write a Readonly Database, which Chmod besides 777 to use?

I am trying to get writing privileges to my sqlite3.db file in my django project hosted on bluehost, but I cannot get any other chmod command to work besides the dangerous/risky chmod 777. When I chmod 777 the db file and the directory, everything works perfectly.

However, in order to be more prudent, I’ve tried chmodding 775 the directory of the sqlite file and chmod 664 the actual db file itself. No luck. I still get OperationalError: Attempt to Write to a Read Only Database whenever I access a feature that requires writing to the db.

I appreciate any assistance.

Upvotes: 2

Views: 332

Answers (1)

thebjorn
thebjorn

Reputation: 27321

The user accessing the database (www-data?) needs to have write privileges to the folder the data resides in as well as the file itself. I would probably change the group ownership (chgrp) of the folder to www-data and add a group sticky bit to the folder as well (chmod g+s dbfolder). The last one makes sure that any new files created belongs to the group owner.

If you're on bluehost you should also have access to MySql (which is a much better choice for web-facing db).

Upvotes: 1

Related Questions