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.

サーバー上のDBからローカルにmysqldumpするコマンドのメモ

Posted at

サーバーdb1上にMySQLデータベースがあるとする。

~/.ssh/config
Host db1
  Hostname xxx.xxx.xxx.xxx
  User root
  Port 22
  IdentityFile ~/.ssh/id_rsa

このとき、ローカルにmysqldumpするコマンドは次のようになる。

ssh db1 "mysqldump -u[user_name] -p[password] --single-transaction [db_name] [tbl_name]" > dump.sql
  • --single-transactionを付けると、ダンプ処理をトランザクションで囲むことにより、LOCK TABLESを行わない。
  • テーブルは空白区切りで複数選択できる。
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?