12
12

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のdump作成・データ投入コマンド

Last updated at Posted at 2014-11-28

すぐ忘れるので書いておく。。

◆Databaseをdumpする
```mysqldump -u [ユーザー名] -p [DB名] > date +%Y%m%d_Database.sql

→日付の文字列。上の例だと"20141128_Database.sql"というようなファイル名になる

◆一部tableだけ除外する
```mysqldump -u [ユーザー名] -p --ignore-table=[DB名].[テーブル名] Database > `date +%Y%m%d_Database.sql`

◆tableをdumpする
```mysqldump -u [ユーザー名] -p [DB名] [テーブル名] > date +%Y%m%d_Table.sql


◆dumpからデータ投入
```mysql -u [ユーザー名] -p --default-character-set=utf8 [DB名] < 20141128_Database.sql

◆tableのdumpからデータ投入

mysql -u [ユーザー名] -p --default-character-set=utf8 [DB名] [テーブル名] < 20141128_Table.sql
```※「--default-character-set=utf8」
→デフォルトの文字コードを指定。何も指定しないとutf8らしい。
12
12
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
12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?