<tfoot id='mj6xN'></tfoot>
    <legend id='mj6xN'><style id='mj6xN'><dir id='mj6xN'><q id='mj6xN'></q></dir></style></legend>
  1. <i id='mj6xN'><tr id='mj6xN'><dt id='mj6xN'><q id='mj6xN'><span id='mj6xN'><b id='mj6xN'><form id='mj6xN'><ins id='mj6xN'></ins><ul id='mj6xN'></ul><sub id='mj6xN'></sub></form><legend id='mj6xN'></legend><bdo id='mj6xN'><pre id='mj6xN'><center id='mj6xN'></center></pre></bdo></b><th id='mj6xN'></th></span></q></dt></tr></i><div id='mj6xN'><tfoot id='mj6xN'></tfoot><dl id='mj6xN'><fieldset id='mj6xN'></fieldset></dl></div>

      <small id='mj6xN'></small><noframes id='mj6xN'>

      • <bdo id='mj6xN'></bdo><ul id='mj6xN'></ul>

    1. 使用 local_infile 的 MariaDB 版本不允许使用的命令

      时间:2024-08-09
          <tbody id='7gu8d'></tbody>
            <tfoot id='7gu8d'></tfoot>
              <bdo id='7gu8d'></bdo><ul id='7gu8d'></ul>

              1. <i id='7gu8d'><tr id='7gu8d'><dt id='7gu8d'><q id='7gu8d'><span id='7gu8d'><b id='7gu8d'><form id='7gu8d'><ins id='7gu8d'></ins><ul id='7gu8d'></ul><sub id='7gu8d'></sub></form><legend id='7gu8d'></legend><bdo id='7gu8d'><pre id='7gu8d'><center id='7gu8d'></center></pre></bdo></b><th id='7gu8d'></th></span></q></dt></tr></i><div id='7gu8d'><tfoot id='7gu8d'></tfoot><dl id='7gu8d'><fieldset id='7gu8d'></fieldset></dl></div>
              2. <small id='7gu8d'></small><noframes id='7gu8d'>

                <legend id='7gu8d'><style id='7gu8d'><dir id='7gu8d'><q id='7gu8d'></q></dir></style></legend>

              3. 本文介绍了使用 local_infile 的 MariaDB 版本不允许使用的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我知道,有几个问题集中在同一个问题上,但所有建议的修复都不适用于我.

                I know, there are a couple of questions out there, that are focusing on the same Issue, but all suggested fixes are not working for me.

                我正在运行一个 PHP 脚本,我在其中尝试使用 LOAD DATA INFILE 将 CSV 文件插入到我的数据库中

                I am running a PHP script in which I a trying to insert a CSV file into my DB using LOAD DATA INFILE like this

                $db = mysqli_init();
                mysqli_options($db, MYSQLI_OPT_LOCAL_INFILE, true);
                mysqli_real_connect($db, $db_host, $db_username, $db_password, $database);
                
                $sql = "LOAD DATA LOCAL INFILE '" . $tpl_vars['filename'] . "' " .
                       "INTO TABLE " . $table_name . " " .
                       "FIELDS TERMINATED BY '" . $tpl_vars['delimiter'] . "' " .
                       "ENCLOSED BY '"" . $tpl_vars['encapsulation'] . "' " .
                       "LINES TERMINATED BY '\n' " .
                       ($tpl_vars['contains_header'] == 1 ? "IGNORE 1 ROWS" : "") . " " .
                       "(" . $columns . ") " .
                       $set;
                
                $db->query($sql);
                

                生成的语句看起来像 thish 并且在语法上是正确的.表中存在的所有列.

                The resulting statement looks like thish and is syntactically right. All columns to exist in the table.

                LOAD data local INFILE '/path/to/file/file.csv' 
                INTO TABLE my_table
                FIELDS TERMINATED BY ';' 
                ENCLOSED BY '"' 
                LINES TERMINATED BY '
                ' 
                IGNORE 1 rows (@category, @title, @price, @description) 
                SET category = @category, title = @title, price = @price, description = @description;
                

                我得到的结果是

                此 MariaDB 版本不允许使用的命令.

                The used command is not allowed with this MariaDB version.

                即使我在 phpMyAdmin 中运行该语句,它也会导致

                Even if I run the statement in phpMyAdmin it results in

                2000 - LOAD DATA LOCAL INFILE 被禁止,检查 mysqli.allow_local_infile

                2000 - LOAD DATA LOCAL INFILE is forbidden, check mysqli.allow_local_infile

                因为我没有对服务器的完全 root 访问权限,所以我使用 ini_get_all() 检查了我的 php.ini,它返回了

                Because I do not have complete root access to my server I checked my php.ini using ini_get_all() and it returned

                mysqli.allow_local_infile: {global_value: "1", local_value: "1", access: 4}

                mysqli.allow_local_infile: {global_value: "1", local_value: "1", access: 4}

                为了检查 my.cnf,我在我的数据库上运行了 SHOW VARIABLES.它回来了

                To check the my.cnf I ran SHOW VARIABLES on my DB. It returned

                local_infile 开启

                local_infile ON

                据我所知,一切都配置得很好,可以运行 LOAD DATA LOCAL INFILE.我错过了什么吗?

                As far as I can see, everything is configured totally fine to run LOAD DATA LOCAL INFILE. Am I missing something?

                我的用户确实有以下 GRANTS

                My user does have the following GRANTS

                GRANT USAGE ON *.* TO 'user'@'localhost' IDENTIFIED BY PASSWORD 'asdf'
                GRANT ALL PRIVILEGES ON `db`.* TO 'user'@'localhost'
                

                我使用的是 MariaDB 10.1.44 和 PHP 5.5.38.

                I am on MariaDB 10.1.44 and PHP 5.5.38.

                推荐答案

                问题似乎是,我的用户没有文件授权.

                It seems that the problem was, that my user did not have File grants.

                GRANT FILE ON *.* TO 'user'@'localhost' IDENTIFIED BY PASSWORD 'asdf'

                成功了.

                这篇关于使用 local_infile 的 MariaDB 版本不允许使用的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:DB插入PHP脚本随机冻结,没有错误日志 下一篇:PHP 允许的内存大小

                相关文章

                    <small id='8v5EA'></small><noframes id='8v5EA'>

                      <bdo id='8v5EA'></bdo><ul id='8v5EA'></ul>
                    <i id='8v5EA'><tr id='8v5EA'><dt id='8v5EA'><q id='8v5EA'><span id='8v5EA'><b id='8v5EA'><form id='8v5EA'><ins id='8v5EA'></ins><ul id='8v5EA'></ul><sub id='8v5EA'></sub></form><legend id='8v5EA'></legend><bdo id='8v5EA'><pre id='8v5EA'><center id='8v5EA'></center></pre></bdo></b><th id='8v5EA'></th></span></q></dt></tr></i><div id='8v5EA'><tfoot id='8v5EA'></tfoot><dl id='8v5EA'><fieldset id='8v5EA'></fieldset></dl></div>

                    <tfoot id='8v5EA'></tfoot>
                    <legend id='8v5EA'><style id='8v5EA'><dir id='8v5EA'><q id='8v5EA'></q></dir></style></legend>