解决linux开发环境常见问题

一、解决java程序读取mysql数据库乱码的问题

      1、打开/etc/my.cnf文件,找到下面内容,然后加入红色内容:

            # The following options will be passed to all MySQL clients  [client]
            # password = your_password
            port = 3306
            socket = /tmp/mysql.sock
            default-character-set=utf8  # 需要我们手动加入的语句

       2、将系统默认编码修改为utf-8,编辑/etc/sysconfig/i18n这个文件,不管你装的是中文版,还是英文版,删掉原来的配置,把下面的拷贝过去,保存,重启mysql服务就可以了。
            LANG="zh_CN.GB18030"
            SUPPORTED="zh_CN.GB18030:zh_CN:zh:en_US.UTF-8:en_US:en"
            SYSFONT="latarcyrheb-sun16"

           

     

猜你喜欢

转载自x125858805.iteye.com/blog/2208296