Home > Backend Development > PHP Tutorial > mysq GBKl garbled code_PHP tutorial

mysq GBKl garbled code_PHP tutorial

WBOY
Release: 2016-07-21 16:00:00
Original
793 people have browsed it

I now have a sql file, the content of which is gbk. Now my display is full of garbled characters.
It can only be displayed using mysql 4.0.26.
It cannot be displayed even if you use 4.1 or above. The head is big. I hope you all can give me some advice, and I’m very grateful.
I have now installed mysql 5.0.22.
I changed the character set in my.ini to gbk, and used the status command to display that they are all gbk. Then I used the source command to import the sql file, but it still no. Before querying, I used set names gbk, set names utf8, set names latin1. Everything showed garbled characters.
Using mysql -uroot -ppassword databaseThe sql file header is like this.
-- MySQL dump 10.10
--
-- Host: localhost Database: system
----------------------- ----------------------------------
-- Server version 5.0.22-community-nt

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION= @@COLLATION_CONNECTION */ ;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/ *!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*

I am speechless. I hope you can give me some advice. Thanks.

Copy the code The code is as follows:

Perfect solution:
1. No matter which method you use, export the SQL text file, make sure EDITPLUS opens and sees Chinese.
2. Change the statement of the SQL file to 4.1, delete the statement of encoding setting, and then save it.
3. Use the command line to import the 4.1 database. Remember, the encoding of this database must be set to GBK. When creating a table, it will be automatically designated as GBK

Attached command:
mysql -hlocalhost -uroot -p**** database --default-character-set=gbk < database.sql

When exporting in the future, also remember --default-character-set=gbk

When writing a program, you must SET NAMES before making a mysql query!

The above is my experience accumulated from countless failures and tests over a long period of time.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/317178.htmlTechArticleI now have a sql file, the content of which is gbk. Now my display is full of garbled characters. It can only be displayed using mysql4.0.26. It can't be displayed even if you use 4.1 or above. The head is big. Hope everyone can point it out...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template