search
HomeDatabaseMysql TutorialLinux下MySQL 3数据库升级到MySQL 4.1乱码问题的完美解决

这两天,研究了一下MySQL升级的乱码问题,终于解决了困扰我很久的问题,这里记录一下,以前相关的文章也已经更新了 以后就可以访问的

这两天,研究了一下MySQL升级的乱码问题,终于解决了困扰我很久的问题,这里记录一下,以前相关的文章也已经更新了

以后就可以访问的更换服务器了

先来看问题描述:

开始的服务器版本: Linux + Apache2.0 + php4.4.0 + mysql3.2.3 无乱码 (SQL导出文件起始地)
开始的本地测试版本: XP + IIS5.1 + php4.4.0 + mysql3.2.3 无乱码
更新的服务器版本: Linux + Apache2.0 + php4.4.0 + mysql4.1 无乱码 (空间提供商上传)
更新的本地测试版本: XP + IIS5.1 + php4.4.0 + mysql4.1 无乱码(不知道为什么,但是后来又乱码了)
最新的本地测试版本: XP + Apache2.0 + php4.4.0 + mysql4.1 乱码....崩溃..3天..未解决..

问题解决:

首先将 sql 文件从服务器上下载下来,或者从什么地方得到这个 sql 执行文件

1. 使用 UltraEdit 打开这个文件,观看文件是否是utf-8格式,下面的状态栏有提示,如果不是文件另存为UTF-8(无BOM)格式,观看文件的中文字符,是否显示正常,显示正常OK,继续

说明: 记着是 UltraEdit ,因为这个软件支持UTF-8编码文件(其他的也可以),windows自带的记事本可能出现匪夷所思的事情,无(BOM)格式也很重要,PHP不支持BOM头... 如果这里无法显示正常的话,不可能往下进行了...我试过,所以说多用不同形式导出几次,使得原始数据正常

2. 如果sql文件出现,新建表指令,注意中间的
ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=101 ;
修改为: ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=101 ;

说明: 本操作就是告诉mysql表使用什么字符集

3. 新建数据库,使用 utf8_general_ci

4. 使用 phpMyAdmin 导入该文件到 mysql4, 导入的文件编码选择 UTF-8

说明: 如果导入错误,看看是否出现语法错误,修改,继续导入

5. 使用 phpMyAdmin 浏览相关记录,观看中文记录是否显示正常,正常继续

6. 浏览你的php程序,观看,读取数据库内容,仍然乱码,在打开数据库 @mysql_connect( $host, $user, $pass ) 类似语句之后添加 @mysql_query("SET NAMES 'utf8'");

7. 刷新网页,OK,成功

说明:

中间任何的过程出现错误,将导致转换失败

这里还有一个问题,就是现在所有的数据,前台数据,数据库数据,和传输过程的数据都用utf-8格式,所以相关的数据量必然会增大,如果网页特别巨大,而且考虑到页面加载问题,可能会出现一点问题
恩,相关的知识就不在这里细说了,我已经写在了这个博客中的"网站开发"类别中,想了解的,可以去看看

个人感觉.很复杂.mysql,phpmyadmin,php,mysql 各个方面都会导致乱码问题.

不过今天解决了 

linux

Statement
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
How do you alter a table in MySQL using the ALTER TABLE statement?How do you alter a table in MySQL using the ALTER TABLE statement?Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

How do I configure SSL/TLS encryption for MySQL connections?How do I configure SSL/TLS encryption for MySQL connections?Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

How do you handle large datasets in MySQL?How do you handle large datasets in MySQL?Mar 21, 2025 pm 12:15 PM

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)?What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)?Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

How do you drop a table in MySQL using the DROP TABLE statement?How do you drop a table in MySQL using the DROP TABLE statement?Mar 19, 2025 pm 03:52 PM

The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.

How do you represent relationships using foreign keys?How do you represent relationships using foreign keys?Mar 19, 2025 pm 03:48 PM

Article discusses using foreign keys to represent relationships in databases, focusing on best practices, data integrity, and common pitfalls to avoid.

How do you create indexes on JSON columns?How do you create indexes on JSON columns?Mar 21, 2025 pm 12:13 PM

The article discusses creating indexes on JSON columns in various databases like PostgreSQL, MySQL, and MongoDB to enhance query performance. It explains the syntax and benefits of indexing specific JSON paths, and lists supported database systems.

How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)?How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)?Mar 18, 2025 pm 12:00 PM

Article discusses securing MySQL against SQL injection and brute-force attacks using prepared statements, input validation, and strong password policies.(159 characters)

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.