-1

I am trying to export mysql table data into CSV file using mysqldump command and getting below error. I have AWS RDS mysql database.

mysqldump: Got error: 1045: Access denied for user 'user1'@'%' (using password: YES) when executing 'SELECT INTO OUTFILE'

below is command i am trying:

mysqldump --tab . -h host1.rds.amazonaws.com -u username1 --password="password" --fields-escaped-by=\\ --fields-terminated-by=, db_name table_name > data.csv
John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • 2
    seems to me the credentials you gave did not work... – J. Chomel Apr 15 '19 at 09:21
  • There is no issue with password as i can connect from mysql command –  Apr 15 '19 at 09:33
  • But, the error says it has to do with the user :) Does the user have the proper priveleges (e.g. not a read only user) – Martijn Apr 15 '19 at 09:34
  • tab is used like this: --tab=dir_name or -T dir_name. Not "--tab dir_name" – filipe Apr 15 '19 at 09:35
  • password maybe should not have " ", I always use -p098jf20 – filipe Apr 15 '19 at 09:36
  • Possible duplicate of [Which are the proper privileges to mysqldump for the Error Access denied when executing 'SELECT INTO OUTFILE'.?](https://stackoverflow.com/questions/9616525/which-are-the-proper-privileges-to-mysqldump-for-the-error-access-denied-when-ex) – Nico Haase Apr 15 '19 at 09:39
  • mysql> GRANT FILE ON *.* TO 'myuser'@'%'; ERROR 1045 (28000): Access denied for user 'myuser'@'%' (using password: YES) mysql> –  Apr 15 '19 at 09:43

1 Answers1

2

In RDS, User doesn't have access to filesystem where DB reside so we can't use above commend.

You can use below command to export data into CSV format.

mysql -u root -p --database=test --host=10.10.01.10 --port=3306 --batch -e "select * from test " | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > test.csv;

  • Thanks it's working but this command is not adding delimiter which i required. Is there any ways we can add delimiter in this command? –  Apr 16 '19 at 07:54
  • Do you know how to add delimiter in mysql command to export data from mysql RDS to CSV file ? –  Apr 17 '19 at 07:57