コマンドプロンプトを開き、mysqlにログインして次の
ようなデータベースにクエリを実行します。バックアップデータベースmybd、exitと入力
してこの開始を終了しますバックアップ:
ファイルでFドライブが正常にバックアップされたことがわかります!
mysqldump -u root -p mydb> F:\ mydb_backup.sql
分析:mysqldump -u root -p(固定形式)+ mydb(データベース名)**> ** F:\ mydb_backup.sql(ストレージパス、mydb_backup.sqlバックアップデータベースの名前です。名前は任意です。サフィックスはsqlにする必要があります)。
回復:
最初に、mydbにあるテーブルをクエリしてみましょう。データベースのテーブルユーザーを誤って削除したとします。
C:\Users\我爱学习>mysql -u root -p123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 28
Server version: 8.0.16 MySQL Community Server - GPL
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use mydb;
Database changed
mysql> show tables;
+----------------+
| Tables_in_mydb |
+----------------+
| users2 |
+----------------+
1 row in set (0.00 sec)
mysql> drop table if exists users2;
Query OK, 0 rows affected (0.03 sec)
mysql> show tables;
Empty set (0.00 sec)
ここで、mydbが空であり、テーブルがないことがわかります。
次にリストアします:
2つの方法:
方法1:
現在のデータベースへの入力:ソース+バックアップデータベースパス
バックアップは成功しました!
テーブルを確認して、users2が戻ってきました
方法2:
現在のデータベースを終了して、次のように入力します:mysql -u root -p database name <backup database path
backup successful!