解决Linux数据库导出到Windows下乱码的问题
前段时间公司服务器做平台迁移,需要将Linux下的MySQL数据库导出到Windows的服务器下。很自然的用了mysqldump指令导出了SQL文件,然后在Windows下进行了MySQL导入操作。导入结束后检查了表数量等等都没问题,于是很自然的以为导入工作顺利完成。 结果哪知道
前段时间公司服务器做平台迁移,需要将Linux下的MySQL数据库导出到Windows的服务器下。很自然的用了mysqldump指令导出了SQL文件,然后在Windows下进行了MySQL导入操作。导入结束后检查了表数量等等都没问题,于是很自然的以为导入工作顺利完成。
结果哪知道后来发现出来了乱码的问题,多次尝试mysqldump导出后导入都不行。于是,只能是编码的问题导致这样的情况了。
Linux系统安装的MySQL,默认的语言是latin1;而Windows下的MySQL在图形化界面安装过程中已经设置默认编码为UTF-8了。看来应该就是这样的问题了,编码问题害死人,经常乱码不说还折腾人
于是网上搜索了一圈,很简单的就解决了,记录解决步骤如下:
1、以Linux下的MySQL默认编码导出数据:
#mysqldump -u USERNAME -pPASSWORD –default-character-set=latin1 [DBname] > [filepath/filename.sql]
其中USERNAME为数据库用户名,一般为root。PASSWORD为密码,也可以不填写,只带上-p标记。最关键的就要数“–default-character-set=latin1”这部分了,一定要跟Linux系统下的编码设置一致。然后DBName为数据库名,后面就是导出的文件路径了。
2、在Windows下用NotePad++、UltraEdit之类的支持多编码格式的文本编辑器打开这个导出的SQL文件,看看有没有乱码。如果没有乱码的话,进行下面的操作。
找到:
CREATE TABLE `table` (
…略…
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
将其改为:
CREATE TABLE `table` (
…略…
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
3、将改好的文件保存成UTF8格式,注意不要添加BOM信息,这样就得到一个UTF8的SQL文档了!
4、执行MySQL导入命令:
mysql -u USERNAME -pPASSWORD [DBname]
5、用phpMyAdmin检查下,现在终于不乱码了,问题解决!
资料参考:http://blog.roga.tw/2008/11/05/1127
原文地址:解决Linux数据库导出到Windows下乱码的问题, 感谢原作者分享。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

In Laravel development, dealing with complex model relationships has always been a challenge, especially when it comes to multi-level BelongsToThrough relationships. Recently, I encountered this problem in a project dealing with a multi-level model relationship, where traditional HasManyThrough relationships fail to meet the needs, resulting in data queries becoming complex and inefficient. After some exploration, I found the library staudenmeir/belongs-to-through, which easily installed and solved my troubles through Composer.

To install Laravel, follow these steps in sequence: Install Composer (for macOS/Linux and Windows) Install Laravel Installer Create a new project Start Service Access Application (URL: http://127.0.0.1:8000) Set up the database connection (if required)

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

There are many ways to customize a development environment, but the global Git configuration file is one that is most likely to be used for custom settings such as usernames, emails, preferred text editors, and remote branches. Here are the key things you need to know about global Git configuration files.
