How do I set up a procedure for MySQL encoding?

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.