mysql5的字符集和sql mode问题
2008-05-29 13:53
190 查看
mysql5添加了一些新的功能的规则,其中对开源程序影响比较大的有两个,一个是4.0.12+开始的4层次字符集,一个是5.0.18开始的默认strict mode。
对于这两个问题,效率最好的解决方案,就是直接修改my.ini
# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=utf8
#这里改成utf-8
# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION"
#这里改成=""
当你没有权限进行修改时,就只好在程序中判断了,必须在每次连接上数据库时进行设定。在使用了数据库抽象层的程序中修改起来也很简单:
if(mysql_get_server_info( $connect ) > '4.0.1')
{
mysql_query( "set names 'utf8'" , $connect );
}
if(mysql_get_server_info( $connect ) > '5.0.1')
{
mysql_query("SET sql_mode=''" , $connect );
}
对于这两个问题,效率最好的解决方案,就是直接修改my.ini
# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=utf8
#这里改成utf-8
# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION"
#这里改成=""
当你没有权限进行修改时,就只好在程序中判断了,必须在每次连接上数据库时进行设定。在使用了数据库抽象层的程序中修改起来也很简单:
if(mysql_get_server_info( $connect ) > '4.0.1')
{
mysql_query( "set names 'utf8'" , $connect );
}
if(mysql_get_server_info( $connect ) > '5.0.1')
{
mysql_query("SET sql_mode=''" , $connect );
}
相关文章推荐
- mysql5的字符集和sql mode问题
- mysql5的字符集和sql mode问题
- Mysql5 字符集编码问题解决
- mysql4.0升级到mysql5(4.1),解决字符集问题
- mysql4.0升级到mysql5(4.1),解决字符集问题
- Mysql5的字符集编码问题解决
- Mysql5 字符集编码问题解决
- mysql5中遇到的字符集问题以及解决办法
- Oracle数据库字符集问题解析
- 影响ORACLE汉字显示的字符集问题
- 关于Hibernate3,mysql5 数据库连接超过8小时 连接超时的问题及解决方案(部分摘自网络)
- 谈谈WEB开发中的苦大难字符集问题
- mysql字符集问题
- python字符集问题
- oracle采用了WE8MSWIN1252字符集乱码的问题
- MySQL字符集 GBK、GB2312、UTF8区别 解决 MYSQL中文乱码问题
- 字符集与编码问题小结
- oracle7.3生成dmp向oracle9i导入字符集乱码问题
- 字符集问题的初步探讨(七)-字符集更改的内部操作
- 谈谈WEB开发中的苦大难字符集问题