MySQL Encoding Issue - Different results from wind

2019-05-13 01:12发布

问题:

I have a MySQL database hosted on a windows server. When I query for a particular record from various windows machines using mysql console I get Päivi (incorrect). When I query for the same record from various *nix machines using mysql console I get Päivi (correct). The query I'm using is a simple SELECT firstname FROM users WHERE id = 12345;.

My database collation is utf8, the field collation is utf8, and I've tried using set names 'utf8'; prior to running my queries.

Why would the windows machines return a different result? Could windows be missing certain characters? Is this normal/expected behavior? I'm not an encoding nor language expert so any feedback would be helpful.

回答1:

After you connect to the server, from the MySQL console client, type the following command to view your current client characterset:

status;

To set it, use the following command:

set names latin1;


回答2:

I'm not sure if a windows console is still multi-byte using the ANSI code page. If so that would be the problem. The results might be correct but the console displays them incorrectly.