导出数据
- 导出表结构和表中数据
mysqldump --default-character-set=utf8mb4 -h192.168.0.1 -uroot -p123456 database tableName > c:\test.sql
- 只导出表中数据(添加-t参数)
mysqldump --default-character-set=utf8mb4 -h192.168.0.1 -uroot -p123456 -t database tableName > c:\test.sql
- 带条件的导出,只导出表中数据,不导出表结构
mysqldump --default-character-set=utf8mb4 -h192.168.0.1 -uroot -p123456 -t database tableName --where="create_time='2022-09-21'" > c:\test.sql
导入数据
1、登录mysql命令管理界面
mysql -h 192.168.0.1 -uroot -p123456
2、选择数据库
use test1;
3、设置字符集编码
set names utf8mb4;
4、执行source命令
source C:/test.sql