Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I create my own database from PHP?

I have a working PHP server. Now I want to use databases (MySQL or something similar). Is it possible to create a database from PHP?

I would like to emphasize that in my case I do not have any user-name and password which I can use to connect to MySQL server. I also do not have a control-panel where I could create a database or a table in an existing database.

ADDED:

I think SQLite is what I need. But if I try to create a new database from PHP I see that PHP tries to create a file in a directory which is different from the directory where my files are supposed to be. Then it reports that it is unable to create the database and I think it is because it tries to create in the directory to which I have no permission to write. Can I force PHP to create SQLite in a specific directory?

like image 839
Roman Avatar asked May 31 '10 13:05

Roman


2 Answers

I'm assuming you want to create an SQL database without access to a stand-alone database server. You could use SQLite, which is a library that creates a lightweight database in a single file without separate processes.

It's not quite as efficient as a standalone database server, however, so if you need performance, use a proper database server. It's not an unreasonable requirement for a high-performance web app.

like image 77
Matti Virkkunen Avatar answered Sep 20 '22 23:09

Matti Virkkunen


Mysql,no. SqlLite is a possibility, you only need write permissions on the filesystem. www.sqlite.org/

like image 40
mhughes Avatar answered Sep 21 '22 23:09

mhughes