Ask coding questions

← Back to all posts
How do I use a database with the new php server?
bitbyte2013 (5)

I am wondering if there is any way to create and access a database from the php server.

Comments
hotnewtop
LuukDev (0)

You can use the normal PHP codes and set your personal info like passwords in a .env file. With the getenv you can get the info without that anyone can see the info.

heyitsmarcus (342)

You can't create a MySQL database on a repl.it instance, as of right now. You can connect to an external database, though, and modify it from a repl.it instance.

heyitsmarcus (342)

@bitbyte2013 If you're not stuck on needing SQL commands, there are some free JSON services you can use such as http://jsonstore.io. It provides a free endpoint for storing JSON data. You can use it to get down what you need for a NoSQL database.

938273849564729 (0)

@heyitsmarcus How would you connect an external database?

heyitsmarcus (342)

@938273849564729 It more or less depends on where your external database is hosted. But, all you should need to do is ensure that you can connect remotely to the database by connecting to the IP of the server hosting it and providing credentials the way you would any other database.

938273849564729 (0)

@heyitsmarcus So if I install a local SQL server, repl.it will be able to connect to it?

heyitsmarcus (342)

@938273849564729 if your local machine will allow a remote connection to the database then yes. You'll have to look up how to enable remote connections to your particular instance of your SQL server.