第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

Mysql導(dǎo)入CSV文件遇到的各種坑

標(biāo)簽:
MySQL

有一个csv文件需要导入到Mysql数据库,总共约600多万行,500Mb大小,用工具导入遇到各种坑。最后决定用load data 命令来导入

1.导入csv文件报错

  • 输入导入命令
    load data infile 'bxltest.csv' into table ty_sale_taocan fields terminated by ',' optionally enclosed by '"' escaped by '"'lines terminated by '\r\n';
  • 报错信息
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
  • 查看设置参数
mysql> show variables like '%secure%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| require_secure_transport | OFF                        |
| secure_auth              | ON                         |
| secure_file_priv         | Null                       |
+--------------------------+----------------------------+

2.设置secure-file-priv选项

2.1 查看Mysql配置文件所在路径

FPMBA:etc eryuefei$ /usr/local/bin/mysqld --verbose --help | grep -A 1 'Default options'
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf 

2.2编辑my.conf配置文件

FPMBA:etc eryuefei$ vi /usr/local/etc/my.cnf
<!--以下是my.conf文件内容-->
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
secure_file_priv = /Users/eryuefei/Downloads
~                                                         
查看配置参数
mysql> show variables like '%secure%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| require_secure_transport | OFF                        |
| secure_auth              | ON                         |
| secure_file_priv         | /Users/eryuefei/Downloads/ |
+--------------------------+----------------------------+
3 rows in set (0.01 sec)

配置成功!

3.重新导入CSV文件

  • 输入导入命令
    load data infile 'bxltest.csv' into table ty_sale_taocan fields terminated by ',' optionally enclosed by '"' escaped by '"'lines terminated by '\r\n';
  • 报错信息
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
  • 报错原因分析

必须要使用绝对路径,而且文件路径必须是在配置的参数底下才不会报错。

  • 修改文件地址,重新导入,导入OK
mysql> load data infile '/Users/eryuefei/Downloads/bxltest.csv' into table ty_sale_taocan fields terminated by ',' optionally enclosed by '"' escaped by '"'lines terminated by '\r\n';

Query OK, 6770972 rows affected (1 min 2.39 sec)
Records: 6770972  Deleted: 0  Skipped: 0  Warnings: 0

终于导入成功,大家也看到了哦,将近680万条数据,导入总共才用了1分多钟。

點(diǎn)擊查看更多內(nèi)容
1人點(diǎn)贊

若覺得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消