MySQL uses UTF8 SQL file for garbled problems

Source: Internet
Author: User

On a station today, open the first page is all garbled, in the browser up a few times encoded characters, are wrong, asked the next PHP development to know that the original SQL file used in the UTF8 code, and my MySQL does not specifically specify the use of that kind of coding, in order not to affect the operation of other stations, Use UTF8 code specifically for this station.
System: CentOS 5.x
MySQL version: MySQL 5.5.x
1. Create a UTF8 database in MySQL first

The code is as follows Copy Code
CREATE DATABASE ' Slogra ' DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;

Just create UTF8 database is not enough, when you import SQL files to specify the UTF8, otherwise the same is garbled.

2. Specify UTF8 format to import SQL

The code is as follows Copy Code
Mysql-u <username>-P--default-character-set=utf8--max_allowed_packet=64m Slogra

Such import will no longer appear garbled.

Ps:
To support large imports, the parameter '--max_allowed_packet=64m ' used above the sets the size of a SQL maximum to Be very large. In some circumstances, you'll need to increase it further, especially if attachments are stored in the database.

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.