PDA

View Full Version : [xubuntu] SQLite databases wont open


The Midnight Coder
July 13th, 2008, 03:59 PM
Config: apache2 + PHP5 + SQLite

I always get errors saying that the database is readonly when I try to open a SQLite database. I tried chmoding to 777 but then it says that it cant open it.

What should I do?

windependence
July 14th, 2008, 04:21 AM
Give your user write access. I'm sorry but I don't know how to do that in SQL lite, but that's why you are getting the errors.

-Tim

The Midnight Coder
July 14th, 2008, 05:32 AM
How do I get the user write access?

windependence
July 14th, 2008, 06:21 AM
As I said, I don't know, but in MySQL you have to grant users access to your database for them to have access.

You should probably check the documentation for how to manage users.

http://www.sqlite.org/

-Tim

The Midnight Coder
July 14th, 2008, 10:10 AM
It needs a user? I dont think so. I used SQLite databases on 110mb.com and it idnt need a usernamr / pass

cpetercarter
July 14th, 2008, 10:17 AM
You do not need a user name and password to access SQLite.
Was the database written by the application which you are now using to try to access it? If not, it could be a problem about SQLite versions - e.g.SQLite 3 trying to open a database written in SQLite 2.

The Midnight Coder
July 14th, 2008, 10:27 AM
I had actually installed SQLite3 earlier and then installed php5-sqlite. Could this have anything to do with it?

And the database was created with my file manager - Thunar

mrmonday
July 14th, 2008, 10:27 AM
Config: apache2 + PHP5 + SQLite

I always get errors saying that the database is readonly when I try to open a SQLite database. I tried chmoding to 777 but then it says that it cant open it.

What should I do?

OK, first off, what is the exact error you are getting? Double check that the script that is trying to access it has the right path to the database. If the file is chmod'ed 777 then he script must be looking in the wrong place - but I can't say for sure without the exact error.

windependence
July 14th, 2008, 10:28 AM
There will still be a user that will access the tables. You don't have to put in a user name and pass, just as you don't in MySQL, but there IS a database user and they must have permission to write to the tables. he is obviously getting an error where the user only has read access. I don't know enough about SQLite to tell him how to do it, but I am pretty sure that is the problem.

chmodding everything to 777 is not an answer either with databases. They can have access permission to the actual file but the database can still restrict who can access the tables and how. Making everything world writable is never a good fix because it is a huge security risk.

-Tim

The Midnight Coder
July 14th, 2008, 10:44 AM
If it works on my 110mb account then why wont it work on localhost?

And even with PHPLiterAdmin it still throws the same errors at me

cpetercarter
July 14th, 2008, 04:22 PM
Yes - Windependence is right. Even though you don't need a username and password to access a SQLite database, as you do for MySQL, for example, there will still be an "owner" of the database. Checking the properties of the SQLite file will reveal who the owner is. For a database generated by an application in localhost, the owner may be www-data.

The Midnight Coder
July 15th, 2008, 08:39 AM
Its not www-data. Its my username.