Linux system garbled problem solution

  

When building a website under linux, the garbled problem has plagued me for almost a week, and finally solved it.

My experience is that the application must match the character set (encoding) of the database.

Specifically, if you want to use gb2312 encoding, you must ensure that each jsp file is stored in gb2312 encoding (you can select gb2312 encoding when saving the file), The file header should also be defined; for the database, the code should be defined when creating the database, for example: create database mysql default character set gb2312 collate gb2312_chinese_ci; the last thing to do is to add the following code to the relevant file when connecting the data:

useUnicode=true&characterEncoding=gb2312.

To add to the explanation, in linux, in fact, do not choose gb2312, I use utf8, of course, you need to follow the above steps to set up, certainly not garbled! Personal preferences, everyone is free! Br>

I tried a lot of methods before, such as changing the system font in /etc/sysconfig/i18n file, adding the following statement after the [mysqld] field in /etc/my.cnf default-character-set=gb2312 Wait, I don't think it is necessary.

The above steps seem to be very simple, but my failure lessons are also my success. Now share it with you. If you have a look after it, if you don’t like it, it’s not your kind!

Forgot, there is a key point, jdbc must use the appropriate version, before I used It was 3.0.9, it was not found, and later it was replaced with 3.0.16, and it was fine.

Copyright © Windows knowledge All Rights Reserved