linux Mysql匯入csv檔案裡的資料

2021-09-25 00:10:52 字數 839 閱讀 9862

在linux伺服器上的mysql資料庫裡匯入csv檔案裡的資料時出現以下問題。

問題1:直接匯入執行(load data infile 「/var/lib/mysql/jgdxhyddcsinfo.csv」 into table jg_jgdx_place_info character set utf8 fields terminated by 「,」;)語句時,如果報secure_file_priv相關的問題,(報錯 error 1290)

處理方式:

1、show variables like 『%secure_file_priv%』—檢視匯入許可權路徑。如果是null。

2、修改/etc/my.cnf,新增secure_file_priv = 『/』 ( '/'為所有的路徑,為了安全,最好到指定路徑)然後重啟mysql (service mysqld restart),再次進入mysql,執行匯入(注意資料庫使用者是否有匯入許可權 )。

問題2:error 1300

處理方式:

1、將excel另存為csv,先別開啟,手動重新命名成txt,然後開啟另存為utf-8,然後再重新命名成csv。

問題3:error 1262

處理方式:

1、show variables like 『%sql_mode%』;

set sql_mode=『no_auto_create_user,no_engine_substitution』 。

執行匯入命令。

load data infile 「/var/lib/mysql/「檔名」.csv」 into table 「表名」 character set utf8 fields terminated by 「,」;

參考:

Linux Mysql資料匯入匯出

一 匯出資料庫用mysqldump命令 注意mysql的安裝路徑,即此命令的路徑 1 匯出資料和表結構 mysqldump u使用者名稱 p密碼 資料庫名 資料庫名.sql 敲回車後會提示輸入密碼 2 只匯出表結構 mysqldump u使用者名稱 p密碼 d 資料庫名 資料庫名.sql 注 usr...

mongodb匯入csv檔案

使用命令 mongoimport 引數 h 主機ip 埠 d 要匯入的db c 要匯入的collections f 指定字段 type 型別 file 匯入的檔案路徑 演示如下 root localhost bin mongoimport h 192.168.1.151 27017 d logs c...

Mysql 匯入csv檔案

mysql load data infile命令可以把csv平面檔案中的資料匯入到資料庫中。linux下 load data infile home test dump ip location.csv into table ip location character set utf8 fields ...