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

前端 未结 21 1553
攒了一身酷
攒了一身酷 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条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 06:21

    in Linux you have to edit my.cnf file in

    /etc/mysql/my.cnf
    

    and change 26 line number param like this :

    secure-file-priv= 
    

    then restart your MySQL and try again.

    in docker you have to mount your my.cnf file with my.cnf file in your container with this command in docker-compose or add manually :

    volumes:
      - ./persistent:/var/lib/mysql
      - ./conf/my.cnf:/etc/mysql/my.cnf
    

    next change /conf/my.cnf in your host and config secure-file-priv param like the upper approach, in addition, you have to mount your data in mysql container and set that path for secure-file-priv param and restart your services and finally, you can load your data.

    you can check your config with this command :

    SHOW VARIABLES LIKE "secure_file_priv";
    

提交回复
热议问题