忍者ブログ
プログラム実験・備忘録
[32] [31] [30] [29] [27] [26] [25] [24] [23] [22] [21]
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

バックアップとリストアで使えるmysqldumpのメモです。

+ + + + + + + + + +
以下実験結果
ユーザ  :root
パスワード:pass
ホスト  :localhost
DB名  :test


実験開始の前に、test_table1が存在するDBを確認
mysql -u root -D test -ppass
mysql> select * from test_table1
    -> ;
+------+
| test |
+------+
| 1    |
| 2    |
| 5    |
| 0    |
| A    |
+------+
5 rows in set (0.01 sec)

mysql> \q
Bye

ダンプを取る(バックアップ)
C:\>mysqldump -u root -ppass test >d:\test.dump

C:\>mysql -ppass -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 5.0.45-community-nt MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.


リストア実験のために、テーブルを削除してみる。
mysql> drop database test;
Query OK, 1 row affected (0.05 sec)

mysql> create database test;
Query OK, 1 row affected (0.00 sec)

mysql> quit;
Bye


バックアップリストア
C:\>mysql -u root -ppass test < d:\test.dump


C:\>mysql -u root -ppass -D test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 5.0.45-community-nt MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> select * from test_table1;
+------+
| test |
+------+
| 1    |
| 2    |
| 5    |
| 0    |
| A    |
+------+
5 rows in set (0.00 sec)

mysql>
実験成功です。
mysqldump の結果を、ちゃんと制御しておけば、
いざと言うときにデータベースを復旧できるわけですな。
Windowsならタスクスケジューラや、Unixならcronなどと組み合わせて、
いざと言うときに備えようと思います。
PR
この記事にコメントする
お名前
タイトル
文字色
URL
コメント
パスワード Vodafone絵文字 i-mode絵文字 Ezweb絵文字
この記事へのトラックバック
この記事にトラックバックする:
広告
プロフィール
negao (45歳  男性)
土木工学卒でなぜかSEやってます。
最近、残業代も出なくなってツライな・・・
ブログ内検索
カウンター
アクセス解析
[32] [31] [30] [29] [27] [26] [25] [24] [23] [22] [21]
Powered by ニンジャブログ  Designed by ゆきぱんだ
Copyright © するのは失敗、何もしないのは、、、 All Rights Reserved
忍者ブログ / [PR]