MySQL's default encoding is Latin, every time the JSP production page inserts the database with INSERT statement, Chinese characters will appear as question mark, after installing MySQL, start service and login, use show variables command to view the default encoding of MySQL database:
The character set of database and server, as shown in the figure above, uses latin1 encoding, and does not support Chinese, that is, garbled characters will appear when storing Chinese. The following is the process of modifying the command line to UTF-8 encoding to support Chinese.
(1) Close MySQL service
[Plain] View plaincopy
Service MySQL Stop
(2) Modify the/ETC/MYSQL/MY.CNF (default installation path)
[Plain] View plaincopy
Vim/etc/mysql/my.cnf
After opening the MY.CNF, add the following two lines to [mysqld] within the file:
[Plain] View plaincopy
Character_set_server=utf8
init_connect= ' SET NAMES UTF8 '
(as shown in the screenshot):
Save exit.
(3) Restart the MySQL service
[Plain] View plaincopy
Service MySQL Start
At this point, complete the modification of the default encoding, landing MySQL after the use of show variable like '%character% ' to obtain the output effect as follows:
Note
The details of the operation and output are as follows:
Workaround: Open MySQL installation directory: C:Program filesmysqlmysql server5.5
Open the file My.ini configuration file, locate the default-character-set=latin1 and change it to:
DEFAULT-CHARACTER-SET=GBK, find character-set-server=latin1 and change it to:
CHARACTER-SET-SERVER=GBK, save after modification.
Finally: My Computer right click "Manage" to enter and select "Services" under "services and Applications"
Right-click to select reboot after locating "MySQL".
<%@ a= "href=" http://www.cr173.com/k/odin/"import=" java.util.* "language=" java "page=" "style=" in JSP pages Text-decoration:underline; Color:rgb (0,82,157) "target=" _blank >odin g= "iso-8859-1"%> instead