How should I tackle --secure-file-priv in MySQL?

前端 未结 21 1202
攒了一身酷
攒了一身酷 2020-11-22 06:04

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;
21条回答
  •  旧时难觅i
    2020-11-22 06:26

    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!

提交回复
热议问题