参考文章:
MySQL mysqldump数据导出详解
windows导出操作记录
Windows上的mysql5.7版本导出操作记录:
(从本地主机的mysql中的pengning的数据库导出到目录E:\MysqlData\databackup\,备份的文件名叫pengning230308.sql
C:\Users\Administrator>mysqldump
Usage: mysqldump [OPTIONS] database [tables]
OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help
C:\Users\Administrator>mysqldump -u root -p -B pengning -r E:\MysqlData\databackup\pengning230308.sql
Enter password: ******** //输入mysql密码
C:\Users\Administrator>
默认不带参数导出的缺少值: 创建数据库判断语句 删除表 创建表 锁表 禁用索引 插入数据 启用索引 解锁表。
Linux导入操作记录
将备份好的数据文件pengning230308.sql通过FTP上传到CentOS7上的/usr/data/pnweb/的目录中,
然后执行下面操作:
[root@campus ~]# mysql -uroot -p
Enter password: //输入mysql密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5517
Server version: 8.0.32 MySQL Community Server - GPL
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
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> source /usr/data/pnweb/pengning230308.sql
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
(.......中间重复忽略)
Database changed
Query OK, 0 rows affected (0.00 sec)
(.......中间重复忽略)
mysql>
打开目标主机的数据库,导入成功。