A perfect solution for upgrading MySQL3 database to MySQL4.1 garbled problem in Linux

Source: Internet
Author: User
Tags ultraedit
In the past two days, I have studied the problem of garbled Characters During MySQL upgrade and finally solved the problem that has plagued me for a long time. Here I will record the issue that can be accessed after the previous articles have been updated.

In the past two days, I have studied the problem of garbled Characters During MySQL upgrade and finally solved the problem that has plagued me for a long time. Here I will record the issue that can be accessed after the previous articles have been updated.

In the past two days, I have studied the problem of garbled Characters During MySQL upgrade and finally solved the problem that has plagued me for a long time. Here I will record it and the previous articles have been updated.

Change the server that can be accessed later

Let's take a look at the Problem description:

Start server version: Linux + Apache2.0 + php4.4.0 + mysql3.2.3 without garbled characters (the start location of the SQL export file)
Start local test version: XP + IIS5.1 + php4.4.0 + mysql3.2.3 without garbled characters
Updated server version: Linux + Apache2.0 + php4.4.0 + mysql4.1 without garbled code (uploaded by the Space Provider)
Updated local test version: XP + IIS5.1 + php4.4.0 + mysql4.1 without garbled code (I don't know why, but it is garbled again later)
Latest local test version: XP + Apache2.0 + php4.4.0 + mysql4.1 garbled... crash... 3 days... unsolved ..

Solution:

First, download the SQL file from the server or obtain the SQL Execution file from somewhere.

1. use UltraEdit to open this file and check whether the file is in UTF-8 format. The following status bar shows a prompt. If the file is not saved as UTF-8 (no BOM) format, check whether the Chinese characters of the file are displayed normally, show normal OK, continue

(Remember is UltraEdit, because this software supports UTF-8 encoding files (Other can also), windows built-in notepad may appear incredible thing, no (BOM) format is also very important, PHP does not support BOM header... if it cannot be displayed normally, it is impossible to proceed... I tried to export the raw data several times in different forms.

2. If the SQL file appears, create a table command. Pay attention to
ENGINE = MyISAM default charset = latin1 AUTO_INCREMENT = 101;
Changed to: ENGINE = MyISAM default charset = utf8 AUTO_INCREMENT = 101;

Note: This operation tells mysql what character set is used.

3. Create a database and use utf8_general_ci

4. Use phpMyAdmin to import the file to mysql4, select the UTF-8 for the imported file encoding

NOTE: If an import error occurs, check whether a syntax error occurs. Modify the syntax and continue the import.

5. Use phpMyAdmin to view related records. Check whether the Chinese records are displayed normally.

6. browse your php program, watch, read the database content, and still garbled. Open the Database @ mysql_connect ($ host, $ user, $ pass) add @ mysql_query ("set names 'utf8'") after similar statements '");

7. Refresh the webpage, OK, succeeded

Note:

An error occurs in any process, leading to conversion failure.

There is another problem here, that is, all the data, front-end data, database data, and data in the transmission process are in UTF-8 format, so the relevant data volume will inevitably increase. If the webpage is extremely large, in addition, some problems may occur due to page loading issues.
Well, the related knowledge is not detailed here. I have already written it in the "website development" category in this blog. If you want to know more, please go and have a look.

Personally, it is very complicated. mysql, phpmyadmin, php, and mysql may cause garbled characters.

But today we have solved it.

,

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.