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 to Grant Permissions to New MySQL UsersHow to Grant Permissions to New MySQL UsersMay 09, 2025 am 12:16 AM

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

How to Add Users in MySQL: A Step-by-Step GuideHow to Add Users in MySQL: A Step-by-Step GuideMay 09, 2025 am 12:14 AM

ToaddusersinMySQLeffectivelyandsecurely,followthesesteps:1)UsetheCREATEUSERstatementtoaddanewuser,specifyingthehostandastrongpassword.2)GrantnecessaryprivilegesusingtheGRANTstatement,adheringtotheprincipleofleastprivilege.3)Implementsecuritymeasuresl

MySQL: Adding a new user with complex permissionsMySQL: Adding a new user with complex permissionsMay 09, 2025 am 12:09 AM

ToaddanewuserwithcomplexpermissionsinMySQL,followthesesteps:1)CreatetheuserwithCREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password';.2)Grantreadaccesstoalltablesin'mydatabase'withGRANTSELECTONmydatabase.TO'newuser'@'localhost';.3)Grantwriteaccessto'

MySQL: String Data Types and CollationsMySQL: String Data Types and CollationsMay 09, 2025 am 12:08 AM

The string data types in MySQL include CHAR, VARCHAR, BINARY, VARBINARY, BLOB, and TEXT. The collations determine the comparison and sorting of strings. 1.CHAR is suitable for fixed-length strings, VARCHAR is suitable for variable-length strings. 2.BINARY and VARBINARY are used for binary data, and BLOB and TEXT are used for large object data. 3. Sorting rules such as utf8mb4_unicode_ci ignores upper and lower case and is suitable for user names; utf8mb4_bin is case sensitive and is suitable for fields that require precise comparison.

MySQL: What length should I use for VARCHARs?MySQL: What length should I use for VARCHARs?May 09, 2025 am 12:06 AM

The best MySQLVARCHAR column length selection should be based on data analysis, consider future growth, evaluate performance impacts, and character set requirements. 1) Analyze the data to determine typical lengths; 2) Reserve future expansion space; 3) Pay attention to the impact of large lengths on performance; 4) Consider the impact of character sets on storage. Through these steps, the efficiency and scalability of the database can be optimized.

MySQL BLOB : are there any limits?MySQL BLOB : are there any limits?May 08, 2025 am 12:22 AM

MySQLBLOBshavelimits:TINYBLOB(255bytes),BLOB(65,535bytes),MEDIUMBLOB(16,777,215bytes),andLONGBLOB(4,294,967,295bytes).TouseBLOBseffectively:1)ConsiderperformanceimpactsandstorelargeBLOBsexternally;2)Managebackupsandreplicationcarefully;3)Usepathsinst

MySQL : What are the best tools to automate users creation?MySQL : What are the best tools to automate users creation?May 08, 2025 am 12:22 AM

The best tools and technologies for automating the creation of users in MySQL include: 1. MySQLWorkbench, suitable for small to medium-sized environments, easy to use but high resource consumption; 2. Ansible, suitable for multi-server environments, simple but steep learning curve; 3. Custom Python scripts, flexible but need to ensure script security; 4. Puppet and Chef, suitable for large-scale environments, complex but scalable. Scale, learning curve and integration needs should be considered when choosing.

MySQL: Can I search inside a blob?MySQL: Can I search inside a blob?May 08, 2025 am 12:20 AM

Yes,youcansearchinsideaBLOBinMySQLusingspecifictechniques.1)ConverttheBLOBtoaUTF-8stringwithCONVERTfunctionandsearchusingLIKE.2)ForcompressedBLOBs,useUNCOMPRESSbeforeconversion.3)Considerperformanceimpactsanddataencoding.4)Forcomplexdata,externalproc

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment