行业新闻
mysql导出数据库命令(导出mysql数据库文件的方法)
2022-02-25 14:08  浏览:0

LOAD DATA INFLIE优点速度快

普通的导入和导出都是使用insert,如果数据量很大的话,速度会比较慢,使用LOAD DATA INFLIE ,比一般的insert语句快20倍。

演示:

1、查看默认导出目录

SHOW VARIABLES LIKE “secure_file_priv”;

结果:C:ProgramDataMySQLMySQL Server 5.7Uploads

2、导出数据到默认目录下的文件

select * INTO OUTFILe “C:\ProgramData\MySQL\MySQL Server 5.7\Uploads\product.txt” from product;

注意如果不导入默认的目录,会报错

注意:不使用默认目录会报错:The MySQL server is running with the –secure-file-priv option so it cannot execute

查看导出的文件结构:和普通的insert很不一样

3、导入数据

load data INFILE ‘C:\ProgramData\MySQL\MySQL Server 5.7\Uploads\product.txt’

into table product

导入成功:速度很快