avn
avn

Reputation: 113

AWS RDS + INTO OUTFILE

I understand that we can't do a INTO OUTFILE when we are dealing with RDS.

From my research, I have tried the following,

mysql -uusername -ppassword -hhost -default-character-set=utf8 dbname < select.sql | sed -e 's/\t/,/g' > test.csv

mysql -uusername -ppassword -hhost -default-character-set=utf8 dbname < select.sql | perl -F"\t" -lane 'print join ",", map {s/"/""/g; /^http://\d.+$/ ? $_ : qq("$_")} @F ' > test.csv

For some reason, if I limit the select query in the select.sql to a certain number, it gave me the correct result with all Arabic wordings intact, but once I increase the limit by 1, the encoding becomes messed up and all Arabic wordings turned to rubbish characters.

I have checked that the CentOS server that I'm running on has the locale set to UTF8 and I have also checked that the data seems to be normal without any issue.

Any idea why this is happening?

Upvotes: 0

Views: 1292

Answers (1)

avn
avn

Reputation: 113

Apparently, there was a column that hosted some contents with BLOB data type which caused the encoding to be messed up when it's being dumped into the csv (might be due to the length of the data and mixed characters), dropping the field as it wasn't used eventually resolved the issue.

Upvotes: 1

Related Questions