I have a real odd one...
I'm outputting a table from a local MySQL database into a text file that has INSERT statements for each record (it's part of a much larger script and is the most efficient way to load data into an Aurora table).
All is working well except for one bug-bear. The first insert adds odd characters in the very first field inserted, but no others.
My insert statement:
.\mysqldump.exe -h localhost -u $localuser --password=$localpass --default-character-set=utf8 --extended-insert=FALSE --add-drop-table abcdatabase exporttable | Out-File $dataoutfile
The first insert statement saya "INSERT INTO exporttable VALUES ('13150',..."
Any idea what those first three characters are and, more importantly, how I get rid of them?
Thanks in advance
Add a comment
|
1 Answer
Ok, so I solved it with thanks to this post link near the bottom a comment by JBurace. I added -Encoding default to the end of the Out-File statement and the problem went away. Bizzare it was only one part of one field, but hey!
1 Comment
TudorIftimie
It is a good practice to choose an encoding instead of default and to force it as the default might change when you upgrade the powershell. The "write-file" has a long history of messing up UTF-8-NoBOM encoding.