With help of our MySQL Support Services have created MySQL error code 1045 load data infile solution article. Bobcares helps you with all your queries.
MySQL error code 1045 load data infile
One of the features of MySQL is loading data from a file directly into a table. However, we need to make sure that the correct permissions assigned to the user performing the import. Or else, the process will fail with the below error message:
mysql> LOAD DATA INFILE '/tmp/product.csv' INTO TABLE name LINES TERMINATED BY '\n';
ERROR 1045 (28000): Access denied for user 'user'@'localhost' (using password: NO)
Here the error indicates that the user does not have the appropriate permissions to perform this kind of operation. The “LOAD DATA INFILE” will be controlled by the FILE global privileges. Ans these privileges will not directly assign to a database or table basis but on the MySQL server level.
To grant a global privilege we require to specify ‘*.*’ rather than ‘{database}.{table}’ which is common for INSERT, UPDATE, SELECT, DELETE privileges. The ‘*’ indicates all.
In this case, we have to perform the below command as a privileged user (root).
GRANT FILE ON *.* TO user@localhost;
Another alternative way to perform the same operation involves updating one of the MySQL server tables as given:
UPDATE mysql.user SET File_priv = 'Y' WHERE Host = 'localhost' AND User = 'user';
FLUSH PRIVILEGES;
[Looking for a solution to another query? We are just a click away.]
Conclusion
To sum up, we need to make sure that the correct permissions are assigned to the user performing the import. And checked the grant privilege permissions added.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments