0

I am trying to dump tables in tsv file but it shows an error

ERROR 1045 (28000): Access denied for user 'user'@'host' (using password: YES)

my command:

mysql -u$DBUser -p$DBPass -D $DBName -e "LOAD DATA INFILE 'file.tsv' INTO TABLE <table>"

My privleges:

Privleges

enter image description here

gen14
  • 21
  • 3

2 Answers2

1

instead of: LOAD DATA INFILE

use: LOAD DATA LOCAL INFILE

gen14
  • 21
  • 3
  • And how would solve that the problem that you can't login? The error message clearly states, that you can't connect to MariaDB server due to providing wrong credentials. – Georg Richter Mar 25 '21 at 06:43
  • Yes. weird but the credentials were correct. I don't know how but it solved problem, I think MySQL should return more meaningful error message – gen14 Mar 25 '21 at 16:35
  • Without `LOCAL`, `LOAD DATA` searches for the file on the server and expects the user to have access to the server's file system (`FILE` grant). With `LOCAL`, `LOAD DATA` searches for a file in the client machine, and the user is not expected to have file system access on the server. My guess is that @gen14 's file was on the client, and their user did not have file system access on the db server. – JavoSN Jul 31 '22 at 01:14
0

When you connect, verify that the "host" seen from the server (in your error message it's just "'host'") is the same for the GRANTs. Here, it must be "localhost". If it is not, then you must add a GRANT for user@whateverappearsintheerrormessage .

(After granting privileges, you must issue the FLUSH PRIVILEGES command).

However, your user probably does not have the FILE global privilege, without which the LOAD DATA INFILE command will not work. See this answer for example.

LSerni
  • 55,617
  • 10
  • 65
  • 107