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

前端 未结 21 1157
攒了一身酷
攒了一身酷 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:18

    This worked for me (had the additional problem of not being able to use LOCAL with my current MySQL version in the statement LOAD DATE INFILE ... )

    sudo /usr/local/mysql/support-files/mysql.server start --secure-file-priv='' --local-infile
    

    The above works for that given path on my machine; you may have to adjust your path.

    Then use:

    mysql -u root -p
    

    One important point is that you should have the CSV in the MySQL data folder. In my machine it is located at: /usr/local/mysql-8.0.18-macos10.14-x86_64/data

    You can change the folder permission if needed to drop a CSV in the data folder.

    Setup:
    macOS Catalina version 10.15.5
    MySQL version 8.0.18

提交回复
热议问题