jsp的程序采用二模式开发的 数据库用的是mysql5.0 
本地开发的时候设置mysql  的字符集为GBK 
如下:+--------------------------+--------+
| Variable_name            | Value  |
+--------------------------+--------+
| character_set_client     | gbk    |
| character_set_connection | gbk    |
| character_set_database   | gbk    |
| character_set_filesystem | binary |
| character_set_results    | gbk    |
| character_set_server     | gbk    |
| character_set_system     | utf8   |
+--------------------------+--------+
在本地开发的时候 测试和使用都正常 ;在chinajsp购买的空间后(带数据库也是mysql5.0的)把程序丢到空间上去后 和数据库相关的东西 英文和数字的可以正常使用 和数据库相关中文部分都不能用了 后来知道了他们的默认字符集是latin1  用alter database dbname default character set gbk collate gbk_chinese_ci 修改后 字符集变为:
+--------------------------+--------+
| Variable_name            | Value  |
+--------------------------+--------+
| character_set_client     | gbk    |
| character_set_connection | gbk    |
| character_set_database   | gbk    |
| character_set_filesystem | binary |
| character_set_results    | gbk    |
| character_set_server     | latin1 |
| character_set_system     | utf8   |
+--------------------------+--------+
并且在连接字符串后面加上了useUnicode=true&characterEncoding=gbk
可是 还是不行 从数据库读出来后还是一堆问号这是怎么回是啊 救命啊!!!

解决方案 »

  1.   


    建议LZ 使用SQLyogEnt工具重新再建数据库SQLyogEnt工具几乎没有出过乱码问题
      

  2.   

    +--------------------------+--------+ 
    ¦   Variable_name                         ¦   Value     ¦ 
    +--------------------------+--------+ 
    ¦   character_set_client           ¦   gbk         ¦ 
    ¦   character_set_connection   ¦   gbk         ¦ 
    ¦   character_set_database       ¦   gbk         ¦ 
    ¦   character_set_filesystem   ¦   binary   ¦ 
    ¦   character_set_results         ¦   gbk         ¦ 
    ¦   character_set_server           ¦   latin1   ¦ 
    ¦   character_set_system           ¦   utf8       ¦ 乱乱的没有这样麻烦的
    SQLyogEnt会帮助你的比myfront好多了
      

  3.   

    在mysql的配置文件里面改,my.ini文件里的内容如下:
    # MySQL Server Instance Configuration File
    # ----------------------------------------------------------------------
    # Generated by the MySQL Server Instance Configuration Wizard
    #
    #
    # Installation Instructions
    # ----------------------------------------------------------------------
    #
    # On Linux you can copy this file to /etc/my.cnf to set global options,
    # mysql-data-dir/my.cnf to set server-specific options
    # (@localstatedir@ for this installation) or to
    # ~/.my.cnf to set user-specific options.
    #
    # On Windows you should keep this file in the installation directory 
    # of your server (e.g. C:\Program Files\MySQL\MySQL Server X.Y). To
    # make sure the server reads the config file use the startup option 
    # "--defaults-file". 
    #
    # To run run the server from the command line, execute this in a 
    # command line shell, e.g.
    # mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
    #
    # To install the server as a Windows service manually, execute this in a 
    # command line shell, e.g.
    # mysqld --install MySQLXY --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
    #
    # And then execute this in a command line shell to start the server, e.g.
    # net start MySQLXY
    #
    #
    # Guildlines for editing this file
    # ----------------------------------------------------------------------
    #
    # In this file, you can use all long options that the program supports.
    # If you want to know the options a program supports, start the program
    # with the "--help" option.
    #
    # More detailed information about the individual options can also be
    # found in the manual.
    #
    #
    # CLIENT SECTION
    # ----------------------------------------------------------------------
    #
    # The following options will be read by MySQL client applications.
    # Note that only client applications shipped by MySQL are guaranteed
    # to read this section. If you want your own MySQL client program to
    # honor these values, you need to specify it as an option during the
    # MySQL client library initialization.
    #
    [client]port=3306[mysql]default-character-set=gb2312
    # SERVER SECTION
    # ----------------------------------------------------------------------
    #
    # The following options will be read by the MySQL Server. Make sure that
    # you have installed the server correctly (see above) so it reads this 
    # file.
    #
    [mysqld]# The TCP/IP Port the MySQL Server will listen on
    port=3306
    #Path to installation directory. All paths are usually resolved relative to this.
    basedir="F:/MySQL/"#Path to the database root
    datadir="F:/MySQL/Data/"# 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=gb2312
    以上红色部分改下
      

  4.   

    how about to start server in gbk
    have a try
    mysqld --character-set-server=gbk -collation-server=gbk_bin
      

  5.   

    我测试过了改变字符编码格式不会影响到以前的数据的。
    通过MySQL Server Instance Config Wizard(自带的)
    或者直接通过my.ini文件修改字符集为GBK(都知道的不细说了),
    重新登录客户端,可以看到字符编码

    character_set_filesystem   ¦   binary   ¦
    character_set_system       ¦   utf8     ¦ 
    外都变为gbk了。
    选择dos对话框上点击右键选择“默认值->选项->默认代码页编码为GBK”
    重启dos进入mysql,用select 查看表中数据是否显示正确";
    如果OK,应该是程式方面的问题了。
    尝试在连接数据库的时候使用
          request.setCharacterEncoding("gbk");
       response.setCharacterEncoding("gbk");
    或者其他字符转化方式试试,在此就不搬门弄斧了。
    如果有问题的在发帖啊!!