LoginSignup
33
44

More than 5 years have passed since last update.

mysql バックアップと復元

Last updated at Posted at 2014-05-06

データベースのバージョン管理ェ…

SQLベースでのバックアップ

# 全てのデータベースをバックアップ
$ mysqldump -u root -x --all-databases > dump.sql
# 特定のデータベースのみバックアップ
$ mysqldump -u root <database_name> > dump.sql
# 複数のデータベースをバックアップする場合はdatabasesオプションを
$ mysqldump -u root --databases DB1 DB2 DB3

mysqldump [OPTIONS] database [tables]とかいう書式でテーブル名も指定できるみたいだ。

SQLベースで復元

普通にmysqlコマンドに渡せばOK

$ mysql -u root -p < dump.sql 
$ mysql -u root database < dump.sql 

メモ

u : user name
p : password
P : port
h : host

d : DDLだけ

33
44
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
33
44