Home > Database > Mysql Tutorial > body text

Mysql导入导出数据结构及数据_MySQL

WBOY
Release: 2016-06-01 13:32:50
Original
951 people have browsed it

bitsCN.com

Mysql导入导出数据结构及数据

 

方式一:

mysqldump -ukevin -P3306 --default-character-set=utf8 -p -h10.1.15.123 activity sign_in_user > user.sql

导出的结果包含建表脚本及数据已INSERT.SQL形式。

 

导入数据

mysql>use activity;

mysql>source user.sql;

 

方式二:

mysql -uactivity -P3306 --default-character-set=utf8 -p -h10.2.8.13 -e "select user_id,mac,phone from activity.sign_in_user" > user.sql

导出的为存数据内容列。不包含表结构

 

导入数据

load data infile "/root/user.sql" into table activity.sign_in_user;

执行以上导入报错:

ERROR 13 (HY000): Can't get stat of '/root/user.sql' (Errcode: 13)

 

之所以要用/tmp目录的原因是mysql默认使用了/tmp作为临时读写目录

load data infile "/tmp/user.sql" into table activity.sign_in_user;

Query OK, 25 rows affected, 5 warnings (0.00 sec)

Records: 25  Deleted: 0  Skipped: 0  Warnings: 2

bitsCN.com
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template