mysql ߣ显示为 ’
当我尝试运行:
mysql -u myUser -pPassword -D myDatabase -h myHost < toInsert.sql
从我的 ubuntu 桌面,其中 myHost 是远程 Red Hat 服务器,并且 toInsert.sql 包含 '
它们显示为 '
我该如何解决此问题?
注意! '
与 '
不同
当我从带有 mysql gui 客户端的 Windows 计算机运行 toInsert.sql 时,我没有这个问题。
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
--default-character-set=utf8
已修复它,因此
mysql -u myUser -pPassword -D myDatabase -h myHost --default-character-set=utf8
toInsert.sql
感谢您的帮助!
--default-character-set=utf8
has fixed itso
mysql -u myUser -pPassword -D myDatabase -h myHost --default-character-set=utf8 < toInsert.sql
thanks for the help!
听起来您的代码对编码感到困惑。定义数据库中字符串数据的编码是什么(我推荐 UTF-8,但只要保持一致,任何东西都可以工作),然后确保您使用的所有工具都意识到这一事实。
当 UTF-8 数据字节被重新解释为 ISO 8859-1 时,“
-
”是“'
”。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.这个问题可能出现在两个地方:
首先,您需要检查数据库中所有内容的编码是否为 UTF-8。
如果这不能解决问题,那么您的数据库可能是正确的,但您的控制台无法显示 UTF-8 字符。将查询的输出通过管道传输到文件中,并在可以显示 UTF-8 字符的文件中查看它,看看它看起来是否正确。如果看起来正确,则问题出在您的终端上。
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.