Convert MYSQL database _ MySQL with UTF8 and latin1 encoding

Source: Internet
Author: User
Convert MYSQL databases that contain UTF8 and latin1 encoding. if someone asks me today, I just turn it around. it's very simple. here I will explain it.
Using phpmyadmin to import data to test, we found that the database contains UTF8 and latin1 encoding, as shown in figure

First, back up test as the test1 Database. in WIN, back up the test directory under path/MySQL/data and change it to the test1 directory.
Delete all tables with UTF8 in phpmyadmin and run
D:/PHPServer/MySQL/bin> mysqldump-uroot-p-quick-compatible = mysql40-default-character-set = latin1-extended-insert = FALSE test> d: /zxs. SQL

Description: D:/PHPServer/MySQL/bin is my installation directory, test is a database, d:/zzz. SQL is the data file generated, the program will prompt you to enter the root user password, enter, wait a few minutes, zxs. SQL is generated.

Create a new library through phpmyadmin, library name: test2, collection character set to utf8-general-li

Import the generated SQL file to the new database.

D:/PHPServer/MySQL/bin> mysql-uroot-p-default-character-set = utf8 test2 <d:/zxs. SQL

Enter the root password. wait a few minutes, and zxs. SQL will be imported successfully. this is not enough, because the latin1 encoding is converted to utf8.
Finally, stop mysql and overwrite all the files in the test2 directory to the test1 directory we just backed up. in this way, the test1 directory is the converted UTF8 database.
Of course, the method is very simple, that is, to separate the latin1 encoded table and convert it into UTF8 and then build the original database. in this way, multiple encodings can be perfectly converted, which is also very common, this can happen if you change the host or upgrade the mysql version.
Of

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.