MySQL garbled problem

Source: Internet
Author: User

A.mysql settings

1.service MySQL Stop

2.sudo vim/etc/mysql/my.cnf

Add the following two lines in [mysqld]

      Character_set_server = UTF8

Init_connect = ' SET NAMES UTF8 '
3.service MySQL Start

B. Building the library and building the table code plus character set encoding

Create Database ' db_name ' DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;

CREATE TABLE ' Tb_name ' (ID varchar (primary) key ...) engine=innodb default character Set=utf8;

or modify the character set encoding for libraries and tables that already exist

    ALTER DATABASE ' db_name ' DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;

    ALTER TABLE ' tb_name ' DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;

C. URL of the call plus character set encoding

url = jdbc:mysql:///' db_name '? Useunicode=true&characterencoding=utf8

MySQL garbled problem

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.