从sql文件导入:
mysql -uroot -ppwd -D db -Ne "source your.sql"
备份sql文件:
mysqldump -uroot -ppwd db table > db.sql
从csv文件导入(需要进入mysql终端 )
>mysql -uroot -p --local-infile
LOAD DATA LOCAL INFILE 'E:/csv/hero_list.csv' REPLACE INTO TABLE hero_list FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES;
LOAD DATA LOCAL INFILE 'E:/csv/hero_layouts.csv' REPLACE INTO TABLE hero_layouts FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES;
经测试在version: 5.5.46有效,而在5.7.20无效
拷贝数据库重命名为另一个库
mysqldump db1 -u root -ppassword --add-drop-table | mysql newdb -u root -ppassword
网友评论