我在 Ubuntu 1804 上使用 Maria DB :
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 37
Server version: 10.1.44-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04
我想做一些相对简单的事情,但我已经浪费了2个小时。我想将文件作为字符串加载。这个网站上有几个问题(其中很多都很老),但没有一个问题能引导我找到解决方案,我已经测试了所有内容,直到完全沮丧。 授予权限:
MariaDB [(none)]> GRANT FILE ON *.* TO matias@localhost;;
Query OK, 0 rows affected (0.00 sec)
ERROR: No query specified
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SHOW GRANTS FOR matias@localhost
-> ;
+------------------------------------------------------------------------------------------------------------------------+
| Grants for matias@localhost |
+------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'matias'@'localhost' IDENTIFIED BY PASSWORD '*???' |
+------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
否secure_file_priv
:
MariaDB [(none)]> SHOW VARIABLES LIKE 'secure_file_priv';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| secure_file_priv | |
+------------------+-------+
1 row in set (0.00 sec)
文件的正确权限:
[~]@Ubuntu1804 #> ls -lh test.txt
-rw-rw-r-- 1 matias matias 6 Feb 29 23:44 test.txt
仍然无法获取文件:
MariaDB [(none)]> SELECT USER();
+------------------+
| USER() |
+------------------+
| matias@localhost |
+------------------+
1 row in set (0.00 sec)
MariaDB [(none)]> SELECT LOAD_FILE('/home/matias/test.txt');
+------------------------------------+
| LOAD_FILE('/home/matias/test.txt') |
+------------------------------------+
| NULL |
+------------------------------------+
1 row in set (0.00 sec)
有人可以指出我解决这个问题的正确方向吗?
所以我尝试使用 Ubuntu 19.10 而不是 18.04,它的效果非常好,
所以,除非有人有魔法卡,这是我能想到的唯一解决方法。
总而言之,它可以在 Ubuntu 16.04 和 19.10 中运行。