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