4
11

More than 5 years have passed since last update.

PostgreSQLの接続方法

Last updated at Posted at 2017-12-17

備忘のためメモ

前提

  • 実行環境はCentOS6.9, PostgreSQL9.5です。他の環境ではやり方が違うかも
  • PostgreSQLがインストールされていること
  • PostgreSQLのパスワード設定されていること
    • 設定されていない場合は sudo passwd postgres で設定する

PostgreSQLに接続する

su - postgres

接続後パスワードが要求されるので入力する

接続するとこんな感じになります

-bash-4.1$ 

psqlと打つことで諸々データベース操作ができるようになる

-bash-4.1$ psql
psql (9.5.10)
"help" でヘルプを表示します.

postgres=# 

データベースに接続する

postgres-# \connect [DB名]
データベース "[DB名]" にユーザ"postgres"として接続しました。

その他の操作

この辺りを参考にやりたいことをやりましょう
PostgreSQLの基本的なコマンド
PostgreSQLコマンドチートシート

参考

UbuntuでPostgreSQLを使ってみよう (2)
CentOS で PostgreSQL を使ってみよう!(2)
CentOS 7にPostgreSQL最新版をインストール
CentOSにPostgreSQL9.5をインストールおよびテスト

4
11
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
4
11