To resolve the error, you must create a user with the following command: mysql> GRANT ALL ON *. * to user_name@localhost IDENTIFIED BY 'password'; Replace user_name with the user's username and password with the user's password.
To disable or enable it explicitly, use the --local-infile=0 or --local-infile[=1] option. For the mysqlimport client, local data loading is not used by default. To disable or enable it explicitly, use the --local=0 or --local[=1] option.
The LOAD DATA INFILE statement reads rows from a text file into a table at a very high speed. If the LOCAL keyword is specified, the file is read from the client host. If LOCAL is not specified, the file must be located on the server. ( LOCAL is available in MySQL 3.22.
The grant privilege allows you to give to other users those privileges you possess. The file privilege gives you permission to read and write files on the server using the LOAD DATA INFILE and SELECT ... INTO OUTFILE statements.
I just ran into this issue as well. I had to add LOCAL
to my SQL statement.
For example, this gives the permission problem:
LOAD DATA INFILE '{$file}' INTO TABLE {$table}
Add LOCAL
to your statement and the permissions issue should go away. Like so:
LOAD DATA LOCAL INFILE '{$file}' INTO TABLE {$table}
I had this problem. I searched around and did not find a satisfactory answer. I summarise below the results of my searches.
The access denied error could mean that:
GRANT FILE on *.* to user@'localhost'
); or,Try using this command:
load data local infile 'home/data.txt' into table customer;
This should work. It worked in my case.
Ensure your MySQL user has the FILE privilege granted.
If you are on shared web hosting, there is a chance this is blocked by your hosting provider.
I found easy one if you are using command line
Login asmysql -u[username] -p[password] --local-infile
then SET GLOBAL local_infile = 1;
select your database by use [db_name]
and finally LOAD DATA LOCAL INFILE 'C:\\Users\\shant\\Downloads\\data-1573708892247.csv' INTO TABLE visitors_final_test FIELDS TERMINATED BY ','LINES TERMINATED BY '\r \n' IGNORE 1 LINES;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With