[这个贴子最后由rosetnt在 2002/11/25 02:55pm 编辑]
select b_id,b_name,b_code,b_state,b_lend,b_click,b_intro from book where b_intro like '%余明%' order by b_code,b_state
我用的mysql版本是3.23.31 ,在mysql中执行这个sql,但查到的结果确不准确, b_intro 是 text 型的。
哪位知道是怎么回事,或怎么解决?
huatong 回复于:2002-11-25 21:08:45
因为mysql的默认字符集不是中文的,可将b_intro的属性设成binary试试
redfox 回复于:2002-11-26 00:20:07
遇到了,无法解决。
rosetnt 回复于:2002-11-26 09:51:34
那怎么样来改变 mysql的默认字符集呢? 我用的是 win32 版的
rosetnt 回复于:2002-11-26 10:41:34
问题解决了~~ :em02:
改变成这个就可以 default-character-set = gb2312 :emn25:
redfox 回复于:2002-11-27 21:03:01
好的,我试试~
redfox 回复于:2002-11-27 21:34:51
好用,gbk亦可。
i叶大马猴 回复于:2002-11-28 02:31:12
那数据类型还要不要改???
redfox 回复于:2002-11-29 16:00:23
不用改
rosetnt 回复于:2002-12-05 10:32:44
redfox~ 你用的mysql是WIN32版本的吗?
linux下的改变后没问题,但WIN32版的mysql当时在控制台改好用,但没有保留住,重起机器后,mysql通过NT的服务启动,又恢复到了默认拉丁文字符集,有办法让他保留住更改后的gb2312值吗?
或者你知道哪有默认就是gb2312字符集的win32版mysql? :emn8:
redfox 回复于:2002-12-05 10:47:37
windows版本修改my.ini
rosetnt 回复于:2002-12-05 11:10:42
是吗? 等等, 说明白点, 是my.cnf 还是 my.ini 我没看到有改这个参数的地方,能具体说明怎么改吗?
rosetnt 回复于:2002-12-05 11:51:18
是my.cnf , 我知道怎么改了 :)
henanups 回复于:2002-12-07 15:05:19
我的3.23.53,试my.ini,在c:\winnt下 我的my.ini内容: #This File was made using the WinMySQLAdmin 1.4 Tool #2002-12-7 8:47:46
#Uncomment or Add only the keys that you know how works. #Read the MySQL Manual for instructions
[mysqld] #默认字符集: default-character-set = gb2312 basedir=C:/Program Files/mysql #bind-address=127.0.0.1 datadir=c:/Program Files/mysql/data #language=c:/Program Files/mysql/share/your language directory #slow query log#= #tmpdir#= #port=3306 #set-variable=key_buffer=16M #最大连接数: set-variable=max_connections=500
[WinMySQLadmin] Server=c:/Program Files/mysql/bin/mysqld-nt.exe user=root password=123
redfox 回复于:2002-12-07 18:10:17
win下面是my.ini
unix下是my.cnf
cndave 回复于:2002-12-09 15:19:09
在window系统下如果用my.cnf,那么把这个文件放在c:\下,如果用my.ini,那么放在c:\winnt下。
飞越巅峰 回复于:2002-12-12 21:53:35
改为GBK后上传图片会出错,折中的办法 方法1: 修改字段类型加binary关键字 alter table <table name>; change <字段名>; <类型>; <字段名>; <类型>; binary
方法2: 在SQL中使用binary关键字 select b_id,b_name,b_code,b_state,b_lend,b_click,b_intro from book where b_intro like binary '%余明%' order by b_code,b_state
redfox 回复于:2002-12-12 22:01:17
上传图片会出错?
tiyi 回复于:2003-01-03 17:44:03
敢问各位使用的是什么版本的mysql ?
faisun 回复于:2003-01-07 10:00:54
如果不改my.ini/my.inf,可不可以办到?
不是我的服务器,我改不了的。
zhxp 回复于:2003-01-07 15:22:12
如果是使用PHP调用MySQL的话,可以在查询结果出来后进行判断(做个函数转化成双字节就可以了)。
冷风 回复于:2003-03-20 09:10:19
改成gb2312编码后就不能上传文件了,谁知道为什么
windlike 回复于:2003-05-07 16:48:34
zhxp 大哥说的
如果是使用PHP调用MySQL的话,可以在查询结果出来后进行判断(做个函数转化成双字节就可以了)。
具体怎样实现,谁知道呀?
buaaytt 回复于:2003-05-18 10:31:48
这样会对通常的英文查询带来影响吗?
buaaytt 回复于:2003-06-01 12:37:14
我是rh9,使用
find / -name my.cnf
居然没找到,那该怎么改啊?
alexann_java 回复于:2004-04-07 12:23:57
首先要把那个中文字段改为binary,然后查询的时候使用mysql自带的一个函数
locate查询就可以了.
select b_id,b_name,b_code,b_state,b_lend,b_click,b_intro
from book
where locate('余明',b_intro) % 2 =1 order by b_code,b_state
ysixin 回复于:2005-06-02 09:00:59
太好了
我终于解决了这样的问题
cbs20 回复于:2005-11-09 13:20:10
修改 /etc/my.cnf
加入
default-character-set = gb2312
重新启动mysql
但是mysql 启动时提示
/usr/local/libexec/mysqld: File '/usr/local/share/mysql/charsets/gb2312.conf' not found (Errcode: 2)
/usr/local/libexec/mysqld: Character set 'gb2312' is not a compiled character set and is not specified in the '/usr/local/share/my
sql/charsets/Index' file
我看了一下'/usr/local/share/mysql/charsets ,确实没有gb2312.conf字符集
ll
total 136
-rw-r--r-- 1 root wheel 621 Jun 30 12:06 Index
-rw-r--r-- 1 root wheel 1758 Jun 30 12:06 README
-rw-r--r-- 1 root wheel 4386 Jun 30 12:06 cp1251.conf
-rw-r--r-- 1 root wheel 4399 Jun 30 12:06 cp1257.conf
-rw-r--r-- 1 root wheel 4385 Jun 30 12:06 croat.conf
-rw-r--r-- 1 root wheel 4386 Jun 30 12:06 danish.conf
-rw-r--r-- 1 root wheel 4384 Jun 30 12:06 dec8.conf
-rw-r--r-- 1 root wheel 4383 Jun 30 12:06 dos.conf
-rw-r--r-- 1 root wheel 4400 Jun 30 12:06 estonia.conf
-rw-r--r-- 1 root wheel 4387 Jun 30 12:06 german1.conf
-rw-r--r-- 1 root wheel 4385 Jun 30 12:06 greek.conf
-rw-r--r-- 1 root wheel 4386 Jun 30 12:06 hebrew.conf
-rw-r--r-- 1 root wheel 4383 Jun 30 12:06 hp8.conf
-rw-r--r-- 1 root wheel 4389 Jun 30 12:06 hungarian.conf
-rw-r--r-- 1 root wheel 4387 Jun 30 12:06 koi8_ru.conf
-rw-r--r-- 1 root wheel 4388 Jun 30 12:06 koi8_ukr.conf
-rw-r--r-- 1 root wheel 4386 Jun 30 12:06 latin1.conf
-rw-r--r-- 1 root wheel 4386 Jun 30 12:06 latin2.conf
-rw-r--r-- 1 root wheel 4545 Jun 30 12:06 latin5.conf
-rw-r--r-- 1 root wheel 4384 Jun 30 12:06 swe7.conf
-rw-r--r-- 1 root wheel 4384 Jun 30 12:06 usa7.conf
-rw-r--r-- 1 root wheel 4400 Jun 30 12:06 win1250.conf
-rw-r--r-- 1 root wheel 4618 Jun 30 12:06 win1251.conf
-rw-r--r-- 1 root wheel 4471 Jun 30 12:06 win1251ukr.conf
不知道你们的gb2312.conf 从哪里搞来的?
|