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

【MySQL】MySQLデータバックアップ・復元方法

Last updated at Posted at 2015-12-11

データバックアップ

全てのデータの場合

$ mysqldump -u root -x --all-databases > dump.sql

特定のデータのみの場合

$ mysqldump -u root -p データベース名 > dump.sql

特定のテーブルを抽出する場合

$ mysqldump -u ユーザー名 -p -t データベース名 テーブル1 テーブル2 ... > ダンプファイル名

データの復元方法

全てのデータの場合

$ mysql -u root -p < dump.sql 

特定のデータのみの場合

$ mysql -u root -p データベース名 < dump.sql 

参照)
http://phpspot.net/php/pgmysqldump%E3%81%A7%E3%83%90%E3%83%83%E3%82%AF%E3%82%A2%E3%83%83%E3%83%97%EF%BC%86%E5%BE%A9%E5%85%83.html

その他(復元の際にデータが重すぎたー!とかの場合)

データが重すぎる場合は、オプションで以下のような設定をしてあげると復元がうまくいく♪

128MまでOKだよ〜というオプションをつけてあげる

mysql --max_allowed_packet=128M -u root -p DB名 < SQLファイル名

構造のみをdumpしてあげる

mysqldump -uUSER_NAME -pPASSWORD --no-data DB_NAME > FILE_NAME
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?