6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

HerokuのPostgreSQLのdbをみる方法

Posted at

Herokuでデータベース絡みのエラーが発生!
何が起きているのかデータベースを覗いてみる方法。

PostgreSQLのバージョンを確認

$ heroku pg:info
=== DATABASE_URL
Plan:                  Hobby-dev
Status:                Available
Connections:           0/20
PG Version:            12.1
Created:               2020-02-21 12:18 UTC
Data Size:             8.3 MB
Tables:                6
Rows:                  10/10000 (In compliance)
Fork/Follow:           Unsupported
Rollback:              Unsupported
Continuous Protection: Off
Add-on:                postgresql-crystalline-37699

psql コマンドが入っていないと見れない

$ heroku pg:psql
--> Connecting to postgresql-crystalline-37699
 ▸    The local psql command could not be located. For help installing psql, see
 ▸    https://devcenter.heroku.com/articles/heroku-postgresql#local-setup

psql コマンドをローカル環境に入れていきましょう!
バージョンを揃えるため、最初に確認したinfoにある 
PG Version: 12.1 をインストールします。

 PostgreSQLをインストール

$ brew install postgresql

これだけです。非常に簡単。

これでpsqlコマンドが使えるようになりました!

$ heroku pg:psql
--> Connecting to postgresql-crystalline-37699
psql (12.2, server 12.1 (Ubuntu 12.1-1.pgdg16.04+1))
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.

おまけ

今までmysqlしか使ったことなかったので
postgreSQLのことはこれから勉強します。。。
分かりやすいコマンドまとめです。
https://dev.classmethod.jp/server-side/db/postgresql-organize-command/

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?