3

I want to install a php script with a database on heroku. How I can get the database name, password, user, and host information for the database I install?

1 Answer 1

8

There are several different databases available on Heroku - you can view the options and add them to your app at addons.heroku.com. Probably the first/most basic database is Postgres - here is the heroku Postgres tutorial. Quoted from the relevant section:

Each database installed on a Heroku app has a unique database URL which can be used by your app to connect to that database. Database URLs take the format postgres://username:password@host:port/database_name.

...

In addition, each app has a DATABASE_URL config var; this is the the database that represents your default database.

Heroku config vars are set as environment variables when your app is created. Thus you can probably read the DATABASE_URL environment variable to get the information you need to connect to your database.

Sign up to request clarification or add additional context in comments.

2 Comments

and which the best database can i use it ??
@Deejay Which database is best probably depends on your needs, and is probably a good topic to research or its own SO Question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.