7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RDS(MySQL)をCSVで出力する際にAccess deniedになってしまう対処法

Posted at

MySQLに接続して、SQL文の後に INTO OUTFILE ... FIELDS TERMINATED BY ... OPTIONALLY ENCLOSED BY ... 続けるとcsvファイルが取得できるとのことだったので試してみたが、 ERROR 1045 (28000): Access denied for user という書き込みエラーになってしまいました。

RDSの環境で実行していたのですが、RDSの場合は以下のようにするとcsv出力ができるみたいです。

mysql -h ${rdshostname} --port ${rdsport} -u ${username} -p${password}  ${databasename} --batch -e "${SQL}" | sed -e 's/^/"/g' | sed -e 's/$/"/g' | sed -e 's/\t/","/g' > /path/to/csv

参考

7
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?