3
4

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 5 years have passed since last update.

[SQL]PostgreSQLのデータをMySQLに移行

Posted at

PostgreSQLのデータを一旦CSVファイルに出力

psql -h ホスト名 -p ポート名 -U ユーザー名 -d DB名 -f select.sql > table.csv
select.sql
copy (テーブル名 or select) to stdout with csv delimiter ',' escape '\' force quote *;

CSVファイルをMySQLにインポート

# インポートするCSVのファイル名はMySQLのテーブル名と一致する必要がある
mysqlimport -h ホスト名 -P ポート名 -u ユーザー名 --fields-terminated-by="," --fields-enclosed-by='"' --lines-terminated-by="\n" --local DB名 table.csv
3
4
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
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?