I am developing a simple PHP application running on Heroku. I have created a CSV file and am using it as a simple database.

Now I want to create a database on Heroku, so I added a Postgres instance and its name is heroku-postgres-9f90a33a::ivory.

I want to know how I can create and manage my database instance to perform actions like creating a table.

有帮助吗?

解决方案

  1. First you login to your heroku account
  2. Then you go to databases section 3 There you create a database by clicking on Create Database
  3. Then your heroku database is created and you get to see its details such as

host = ...

database = ...

User = ...

Port = ...

Password = ...

Now Connect to the database using PostgreSQL’s interactive terminal client.

If you don't have it already installed then you’ll have to turn to your platform’s package management suite (e.g. on Ubuntu run sudo apt-get install postgresql-client) or go to postgresql.org, where you’ll find available for download pre-built binary packages suitable for FreeBSD, Linux, Mac, Solaris and Windows, as well as other installation options.

To connect, call psql with the -h option to specify the server’s hostname, -U to specify     the username, and then the database name:

root@yogesh-System-model:~# psql -h [**Host Name**] -U [**User Name**] [**database Name**]
    Password for user hdwvhbehqlishy: ********
    psql (8.4.9, server 9.0.5)
    WARNING: psql version 8.4, server version 9.0.
     Some psql features might not work.
    SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
    Type "help" for help.


df7r55a12o64m4==> CREATE TABLE [Table_name](your_id SERIAL, Name text, Address text);

That will create a table....

I know owner of this question has already solved the problem but still posting this answer for future references....

If any problems can refer this tutorial

This is one way.....another way would be using Jack DB in which you will be able to fire any queries and see the data in your DB located at Heroku.

其他提示

With current Heroku (7.54.1), if the database is your app's primary (which it is by default), you can log in to the psql cli with:

heroku pg:psql --app <name-of-your-app>

Then continue as in the accepted answer.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top