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.