CentOS7のmariadbでLOAD_FILEが動作しません。
FILE権限やsecure-file-privの設定については一通り試したのですが全く動作しません。
https://mariadb.com/kb/en/library/load_file/
に従って設定を行いました。
どなたかこの状況を解決できる方法はご存知ではありませんか?
テストを行った環境
$ more /etc/redhat-release CentOS Linux release 7.6.1810 (Core) $ rpm -qa | grep maria mariadb-libs-5.5.60-1.el7_5.x86_64 mariadb-server-5.5.60-1.el7_5.x86_64 mariadb-5.5.60-1.el7_5.x86_64
my.cnfで
secure-file-priv="/tmp/"
を追記済み
mariadbではLOAD_FILEが動作しない
$ mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 2 Server version: 5.5.60-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> SELECT @@secure_file_priv; +--------------------+ | @@secure_file_priv | +--------------------+ | /tmp/ | +--------------------+ 1 row in set (0.00 sec) MariaDB [(none)]> select load_file('/tmp/test.txt'); +----------------------------+ | load_file('/tmp/test.txt') | +----------------------------+ | NULL | +----------------------------+ 1 row in set (0.00 sec) MariaDB [(none)]> SHOW GRANTS FOR root@'localhost'; +---------------------------------------------------------------------+ | Grants for root@localhost | +---------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION | | GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION | +---------------------------------------------------------------------+ 2 rows in set (0.00 sec) MariaDB [(none)]> SELECT @@max_allowed_packet; +----------------------+ | @@max_allowed_packet | +----------------------+ | 134217728 | +----------------------+ 1 row in set (0.00 sec)
なお、my.cnfにての設定を
secure-file-priv=""
とすると
MariaDB [(none)]> SELECT @@secure_file_priv; +--------------------+ | @@secure_file_priv | +--------------------+ | NULL | +--------------------+ 1 row in set (0.00 sec)
となります。
【実験】同一OS環境のmysqlでは問題なく動作する
$ more /etc/redhat-release CentOS Linux release 7.6.1810 (Core) $ rpm -qa | grep mysql mysql-community-server-5.7.26-1.el7.x86_64 mysql-community-common-5.7.26-1.el7.x86_64 mysql-community-client-5.7.26-1.el7.x86_64 mysql57-community-release-el7-10.noarch mysql-community-libs-compat-5.7.26-1.el7.x86_64 mysql-community-libs-5.7.26-1.el7.x86_64 $ mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.26 MySQL Community Server (GPL) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> SELECT @@secure_file_priv; +--------------------+ | @@secure_file_priv | +--------------------+ | /tmp/ | +--------------------+ 1 row in set (0.00 sec) mysql> select load_file('/tmp/test.txt'); +----------------------------+ | load_file('/tmp/test.txt') | +----------------------------+ | hoge | +----------------------------+ 1 row in set (0.00 sec) mysql> SHOW GRANTS FOR root@'localhost'; +---------------------------------------------------------------------+ | Grants for root@localhost | +---------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION | | GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION | +---------------------------------------------------------------------+ 2 rows in set (0.00 sec) mysql> SELECT @@max_allowed_packet; +----------------------+ | @@max_allowed_packet | +----------------------+ | 4194304 | +----------------------+ 1 row in set (0.00 sec)
こちらでmy.cnfの設定を
secure-file-priv=""
とすると
mysql> SELECT @@secure_file_priv; +--------------------+ | @@secure_file_priv | +--------------------+ | | +--------------------+ 1 row in set (0.00 sec)
となります。
mariadbではここをNULLでは無い空文字列にする方法は無いのかも気になります。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/20 12:27
2019/06/20 12:35
2019/06/20 12:38
2019/06/21 00:25 編集