Mysql 导入导出数据结构及数据
方式一:
mysqldump -ukevin -P3306 --default-character-set=utf8 -p -h10.1.15.123 activity sign_in_user > user.sql
導(dǎo)出的結(jié)果包含建表腳本及數(shù)據(jù)已INSERT.SQL形式。
導(dǎo)入數(shù)據(jù)
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
導(dǎo)出的為存數(shù)據(jù)內(nèi)容列。不包含表結(jié)構(gòu)
導(dǎo)入數(shù)據(jù)
load data infile "/root/user.sql" into table activity.sign_in_user;
執(zhí)行以上導(dǎo)入報(bào)錯(cuò):
ERROR 13 (HY000): Can't get stat of '/root/user.sql' (Errcode: 13)
之所以要用/tmp目錄的原因是mysql默認(rèn)使用了/tmp作為臨時(shí)讀寫目錄
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
轉(zhuǎn)載于:https://www.cnblogs.com/snake-hand/p/3144840.html
總結(jié)
以上是生活随笔為你收集整理的Mysql 导入导出数据结构及数据的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: webstorm 快捷键持续更新中...
- 下一篇: 一个 SQL 同时验证帐号是否存在、密码