关于mysql在linux下面字符修改的问题
来源:互联网 发布:乐视tv网络连接错误 编辑:程序博客网 时间:2024/05/16 06:15
You inserted CJK characters with INSERT
, but when you do a SELECT
, they all look like “?”. It usually is a setting in MySQL that doesn't match the settings for the application program or the operating system. These are common troubleshooting steps:
-
Find out: what version do you have? The statement
SELECT VERSION();
will tell you. This FAQ is for MySQL version 5, so some of the answers here will not apply to you if you have version 4.0 or 4.1. -
Find out: what character set is the database column really in? Too frequently, people think that the character set will be the same as the server's set (false), or the set used for display purposes (false). Make sure, by saying
SHOW CREATE TABLE tablename
, or better yet by saying this:SELECT character_set_name, collation_nameFROM information_schema.columns WHERE table_schema = your_database_nameAND table_name = your_table_nameAND column_name = your_column_name;
-
Find out: what is the hexadecimal value?
SELECT HEX(your_column_name)FROM your_table_name;
If you see
3F
, then that really is the encoding for?
, so no wonder you see “?”. Probably this happened because of a problem converting a particular character from your client character set to the target character set. -
Find out: is a literal round trip possible, that is, if you select “literal” (or “_introducer hexadecimal-value”) do you get “literal” as a result? For example, with the Japanese Katakana Letter Pe, which looks like
ペ'
, and which exists in all CJK character sets, and which has the code point value (hexadecimal coding)0x30da
, enter:SELECT 'ペ' AS `ペ`; /* or SELECT _ucs2 0x30da; */
If the result doesn't look like
ペ
, a round trip failed. For bug reports, we might ask people to follow up withSELECT hex('ペ');
. Then we can see whether the client encoding is right. -
Find out: is it the browser or application? Just use mysql (the MySQL client program, which on Windows will be mysql.exe). If mysql displays correctly but your application doesn't, then your problem is probably “Settings”, but consult also the question about “Troubles with Access (or Perl) (or PHP) (etc.)” much later in this FAQ.
To find your settings, the statement you need here is
SHOW VARIABLES
. For example:mysql>
SHOW VARIABLES LIKE 'char%';
+--------------------------+----------------------------------------+| Variable_name | Value |+--------------------------+----------------------------------------+| character_set_client | utf8 || character_set_connection | utf8 || character_set_database | latin1 || character_set_filesystem | binary || character_set_results | utf8 || character_set_server | latin1 || character_set_system | utf8 || character_sets_dir | /usr/local/mysql/share/mysql/charsets/ |+--------------------------+----------------------------------------+8 rows in set (0.03 sec)The above are typical character-set settings for an international-oriented client (notice the use of
utf8
Unicode) connected to a server in the West (latin1
is a West Europe character set and a default for MySQL).Although Unicode (usually the
utf8
variant on Unix, usually theucs2
variant on Windows) is better than “latin”, it's often not what your operating system utilities support best. Many Windows users find that a Microsoft character set, such ascp932
for Japanese Windows, is what's suitable.If you can't control the server settings, and you have no idea what your underlying computer is about, then try changing to a common character set for the country that you're in (
euckr
= Korea,gb2312
orgbk
= People's Republic of China,big5
= other China,sjis
orujis
orcp932
oreucjpms
= Japan,ucs2
orutf8
= anywhere). Usually it is only necessary to change the client and connection and results settings, and there is a simple statement which changes all three at once, namelySET NAMES
. For example:SET NAMES 'big5';
Once you get the correct setting, you can make it permanent by editing
my.cnf
ormy.ini
. For example you might add lines looking like this:[mysqld]character-set-server=big5[client]default-character-set=big5
- 关于mysql在linux下面字符修改的问题
- 关于linux环境下修改mysql字符编码的问题
- linux下面的mysql各种问题
- 关于linux下部署 tomcat+mysql 的中文字符问题
- linux下面mysql的安装和相关的修改命令
- 在linux下面删除MySQL
- 修改linux下面的字符集
- 关于在win8下面安装虚拟机出现的一些问题
- 关于在windows下面虚拟机创建linux的hadoop配置
- mysql程序在linux下面的编译方法
- Linux系统下修改MySQL字符编码问题
- linux mysql安装与修改字符编码(乱码问题)
- 解决phpmailer可以在windows下面发送成功, 在linux下面失败的问题
- 主题:关于在linux中无法启动MySQL的问题.
- 修改MySQL字符编码【Linux】
- mysql linux 下面的安装
- LINUX下面mysql的安装
- 关于修改mysql字符集的问题
- winxp双击驱动器图标不能进入,必须点击右键"打开"
- 通用打印类
- 解决“无法开始调试。无法找到Microsoft Internet Explorer”错误
- 中国各省省名的由来
- 关于ProcessID和ThreadID
- 关于mysql在linux下面字符修改的问题
- 设计模式9.5
- I have made a decision
- 写给自己
- java rss lib 评测
- 目标主机MAC 地址,第三方测试代码
- linux+jdk+tomcat+mysql
- input readonly
- javascript常用代码