views:

75

answers:

3

Hi there, when I try and run:

mysql -u myUser -pPassword -D myDatabase -h myHost < toInsert.sql

from my ubuntu desktop where myHost is a remote Red Hat server and toInsert.sql contains they show up as ’

How can I resolve this?

Note! is NOT the same as '

When I run toInsert.sql from a windows machine with a mysql gui client I do not have this problem.

Thanks

+1  A: 

Sounds like you've got code that's confused about encodings. Define what the encoding of the string data in the database is (I recommend UTF-8, but anything will work so long as you're consistent) and then make sure that all the tools you use with it realize that fact.

And “’” is a “” when the UTF-8 data bytes are reinterpreted as ISO 8859-1.

Donal Fellows
Thank you for your help! It helped me get to the solution!
+1  A: 

There are two places this problem could be:

First, you need to check that the encoding on everything in your database is UTF-8.

If that doesn't fix it, then your database might be correct, but your console is unable to display UTF-8 characters. Pipe the output of a query into a file and view it in something that can display UTF-8 characters and see if it looks correct. If it looks correct, then the problem is your terminal.

Stargazer712
hmm, well, I have run this... "mysql> SHOW VARIABLES LIKE 'character\_set\_%';" and I get: character_set_client: latin1, character_set_connection: latin1, character_set_database: utf8, character_set_filesystem: binary, character_set_results: latin1, character_set_server: latin1, character_set_system: utf8could it be the latin1's kicking around? But regardless, I'm not really at liberty to change those. And my terminal shows the characters fine. But oddly, last night (home from work) I tried it through some reverse ssh tunnels and it worked.
Thank you for your help! It helped me get to the solution!
A: 

--default-character-set=utf8 fixed it

so

mysql -u myUser -pPassword -D myDatabase -h myHost --default-character-set=utf8 < toInsert.sql thanks for the help!

You should mark the most helpful answer accepted.
BalusC
I had to wait 24 hours to do that, this was mandated by stackoverflow.com I would happily vote up the other two but I don't have a high enough rep yet. In the interest of helping others out I posted the the fix I figured out after giving the mysql man page a closer read.