例如:需要备份和恢复的数据库hellow,数据库root密码:fZmZNXAfywpF7PMz
将数据库当中的数据导出
在windows的dos命奈窗口中执行(导出整个数据库):
mysqldump hellow>C:\hellow2019_11_01.sql -uroot -pfZmZNXAfywpF7PMz
在windows的dos命令窗口中执行(导指定数据库中的指定表emp):
mysqldump hellow emp>C:\hellow_emp2019_11_01.sql -uroot -pfZmZNXAfywpF7PMz
导入数据库
create database hellow;
use hellow;
source C:\hellow2019_11_01.sql
一些操作流程(作为了解)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| hellow |
| mysql |
| performance_schema |
| test |
+--------------------+
8 rows in set (0.00 sec)
mysql> drop database hellow;
Query OK, 4 rows affected (0.06 sec)
mysql>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
7 rows in set (0.00 sec)
mysql> create database hellow;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| hellow |
| mysql |
| performance_schema |
| test |
+--------------------+
8 rows in set (0.00 sec)
mysql> use hellow;
Database changed
mysql> source C:\hellow2019_11_01.sql