【问题标题】:MySQL Data Import with secure_file_priv issue带有secure_file_priv问题的MySQL数据导入
【发布时间】:2021-01-17 06:45:03
【问题描述】:

我有一个关于 MySQL 数据导入的新手问题。

我正在尝试将 .csv 文件导入我的 MySQL 数据库,然后出现“secure_file_priv”错误,我花了一整天的时间去谷歌尝试,我发现 secure_file_priv 的值是 '/var/lib/ mysql-files',因为我使用的是 Centos 8。我将 csv 文件放入目录中,但它一直显示相同的错误。

我的代码:

mysql> show variables like "secure_file_priv";
+------------------+-----------------------+
| Variable_name    | Value                 |
+------------------+-----------------------+
| secure_file_priv | /var/lib/mysql-files/ |
+------------------+-----------------------+
1 row in set (0.01 sec)

mysql> load data infile '/var/lib/mysql-files/master.clientlist.csv'
-> into table agentcompany_compare
-> fields terminated by ','
-> lines terminated by '\n'
-> ignore 1 rows;
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv 
option so it cannot execute this statement

【问题讨论】:

  • 设置说“文件”,你的代码说“文件”
  • /var/lib/mysql-files/ 不等于 `\var\lib\mysql-file` 斜杠与反斜杠
  • 'var/lib/mysql-files/master.clientlist.csv' #非常感谢您指出语法,但它仍然不起作用..同样的错误
  • 我已经用 outfile 测试过,效果很好,但是不能用 infile,阅读谷歌的每一篇文章仍然没有头绪..
  • 好吧,我现在继续前进,现在它说我没有正确的整数值,如果我解决了,我会继续更新。

标签: mysql centos


【解决方案1】:

新进展:

我不知道,但它“有效”,但没有数据正确写入 mysql,请查看我的代码:

mysql>  load data infile '/var/lib/mysql- 
files/clientlist.csv' into table agentcompany_compare
-> fields terminated by ','
-> lines terminated by ';\n'
-> ignore 1 rows;
Query OK, 0 rows affected (0.01 sec)
Records: 0  Deleted: 0  Skipped: 0  Warnings: 0

我已经尝试了很多,供您参考:

mysql> load data infile '/var/lib/mysql- 
files/clientlist.csv' into table agentcompany_compare
-> fields terminated by ','
-> lines terminated by ';\n';
ERROR 1300 (HY000): Invalid utf8mb4 character string: 
'idagentcompany   acid   acname   actel   acaddress       
logo
1       1       "
'

mysql> load data infile '/var/lib/mysql- 
files/clientlist.csv' into table agentcompany_compare
-> fields terminated by ','
-> lines terminated by '\r\n';
ERROR 1366 (HY000): Incorrect integer value: 
'idagentcompany    acid    acname actel    acaddress       
logo' for column 'idagentcompany' at row 1

难题。

【讨论】:

    猜你喜欢
    • 2012-10-27
    • 2017-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-06
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多