0
0

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 1 year has passed since last update.

PostgreSQLのbakファイルの導入(一旦削除と再作成)

Last updated at Posted at 2022-11-16

PostgreSQLのダウンロード:

PostgreSQLを操作できるアプリ:

PostgreSQLのデータ(.bak)導入:

直接にpsqlで導入すると、エラーが発生する場合、データベース一旦削除して再作成するため:

(以下の操作はSQL言語ですので、pgAdmin4の[Query Tool]またはDBeaverの[SQL エディタ]で操作する可能)

  • DB削除:
    • アクティブの項目を停止
select * from pg_stat_activity
select pg_terminate_backend([pid])
  • DB削除
    DROPコマンドでDBを削除する
DROP DATABASE [DBname]
  • DB削除(ターミナル):

    ターミナルでDBを削除する可能:
  • DBに関するプロセスを探す:
ps aux|grep [DB名]
  • プロセスを停止:
kill [pid]
  • DBを削除する:
dropdb -U [ユーザー名] -h [ipアドレス] [DB名]
  • psqlでデータ導入:
  • DB作成
create DATABASE [MercuryDB名] 
  • データ導入
psql -h [ip address] -U [username] [MercuryDB名] < [MercuryDB.bakファイル] (ファイルのパスを含む)
  • psqlでデータ導入(ターミナル):

    ターミナルでDBを再作成とデータ導入する可能:
  • DB作成
createdb -U [ユーザー名] -h [ipアドレス] [DB名]
  • データ導入
psql -h [ip address] -U [username] [MercuryDB名] < [MercuryDB.bakファイル] (ファイルのパスを含む)
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?