I am learning MySQL and tried using a LOAD DATA
clause. When I used it as below:
LOAD DATA INFILE \"text.txt\" INTO table mytable;
If you're running on Ubuntu, you may also need to configure Apparmor to allow MySQL to write to your folder, e.g. here's my configuration:
Add this line to file /etc/apparmor.d/usr.sbin.mysqld :
/var/lib/mysql-files/* rw
Then add these 2 config lines to /etc/mysql/my.cnf sections:
[client]
loose-local-infile = 1
[mysqld]
secure-file-priv = ""
Here's my SQL:
select id from blahs into outfile '/var/lib/mysql-files/blahs';
It worked for me. Good luck!
On Ubuntu 14 and Mysql 5.5.53 this setting seems to be enabled by default. To disable it you need to add secure-file-priv = ""
to your my.cnf file under the mysqld config group. eg:-
[mysqld]
secure-file-priv = ""
This thread has been viewed 570k times at the time of this post. Honestly when did MySQL become our over protective unreasonable mom? What a time consuming attempt at security - which really only serves to shackle us!
After many searches and many attempts everything failed. My solution:
What worked for me was:
.csv
file via PhpMyAdmin import on older box (if large do at cmd line).sql
file..sql
file..sql
file via MySQL Workbench.