How to create or manage heroku_postgres database instance

蓝咒 提交于 2019-12-03 06:05:00

问题


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:


  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.



来源:https://stackoverflow.com/questions/20775490/how-to-create-or-manage-heroku-postgres-database-instance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!