数据库名称&用户&密码&在heroku上主持 [英] Database name & user & password & host on heroku
问题描述
我想在heroku上安装一个带有数据库的php脚本。我可以如何获得我安装的数据库的数据库名称,密码,用户和主机信息?
Heroku上提供的数据库 - 您可以在上查看选项并将其添加到您的应用程序中。可能是第一个/最基本的数据库是Postgres - 这里是heroku Postgres教程。引用自相关部分:
安装在Heroku应用程序上的每个数据库都有一个唯一的数据库URL,您的应用程序可以使用该URL来连接到该数据库。数据库URL采用格式postgres:// username:password @ host:port / database_name。
...
...
<另外,每个应用程序都有一个DATABASE_URL config var;这是代表您的默认数据库的数据库。
Heroku config vars 被设置为应用程序创建时的环境变量。因此,您可以阅读 DATABASE_URL
环境变量以获取连接到数据库所需的信息。
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?
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.
这篇关于数据库名称&用户&密码&在heroku上主持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!