mysql导入与导出表数据

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wuzqChom/article/details/79934466

在使用mysql将csv文件导入数据库的表中的时候出现如下错误:
ERROR 1148 (42000): The used command is not allowed with this MySQL version
解决方案如下:
通常我们进入mysql数据库的命令是:

mysql -u root -p

然后输入密码。
这里只需要将进入数据库的命令改成:

mysql --local-infile=1 -u root -p

即可。
然后使用命令:

load data local infile [path] into table users 
fields terminated by ',' optionally enclosed by '"' 
escaped by '"' lines terminated by '\n' IGNORE 1 ROWS;

最后一行是为了忽略表头

导出数据的使用方式

select * from test_info   
into outfile [path]   
fields terminated by ','   
optionally enclosed by '"' 
escaped by '"'        
lines terminated by '\n';

注:需要保证写出的目录拥有’w’的权限


猜你喜欢

转载自blog.csdn.net/wuzqChom/article/details/79934466
今日推荐