shell命令
root@debian:~# mysqlimport -uroot -p123456 --fields-terminated-by=',' --fields-enclosed-by='"' --fields-escaped-by='"' database_name /var/lib/mysql-files/table_name.csv
參數說明:
–fields-terminated-by,字段間的分割符。
–fields-enclosed-by,單字段的前后分界限符。
–fields-escaped-by,轉義字符。
database_name,庫名。
table_name,即是文件名又是表名,必須一致。
常見問題
mysqlimport: Error: 1290, The MySQL server is running with the --secure-file-priv option so it cannot execute this statement, when using table: ...
MySQL啟動參數–secure-file-priv,指定了一個目錄,默認是/var/lib/mysql-files/,要導入的文件必須放在此目錄下,否則在會出現如上錯誤。