Resolving "ERROR: Loading local data is disabled" Issue: A Step-by-Step Guide
The error message "ERROR: Loading local data is disabled" indicates that local data loading is not enabled on both the client and server sides. To resolve this issue, follow these steps:
Step 1: Enable Local Data Loading on the Server Side
mysql> SET GLOBAL local_infile=1;
mysql> SHOW GLOBAL VARIABLES LIKE 'local_infile';
You should see Value | ON.
Step 2: Enable Local Data Loading on the Client Side
mysql> quit
mysql --local-infile=1 -u <username> -p
Step 3: Load the Data into Your Database
mysql> LOAD DATA LOCAL INFILE 'path/to/your_data.csv' INTO TABLE your_table;
Example:
Imagine you want to load a CSV file named toys.csv into a table called toys:
CREATE TABLE toys ( ... ); LOAD DATA LOCAL INFILE '/Users/BruddaDave/Desktop/toys.csv' INTO TABLE toys FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' IGNORE 1 LINES (..., ...);
After completing these steps, you should be able to successfully load your local data into your MySQL database without encountering the "ERROR: Loading local data is disabled" issue.
The above is the detailed content of How to Fix the 'ERROR: Loading local data is disabled' MySQL Error?. For more information, please follow other related articles on the PHP Chinese website!