Import mysqldump utf-8 database to latin1

I have a phpnuke site dump file somehow in utf8. I am trying to open this site on a new server. But Nuke uses latin1. I need a way to create a latin1 database using this utf-8 dump file. I tried everything I could think of. iconv, mysql replace, php replace ...

+4
source share
1 answer

Add the statement SET NAMES 'utf8'; at the beginning of your dump. This will tell MySQL that the commands it is about to receive are in UTF8. It will store data in any character currently set in your tables; in this case, if your database is in latin1, the data will be stored in latin1.

From http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html :

SET NAMES indicates which character set the client will use to send SQL statements to the server. Thus, SET NAMES "cp1251" tells the server, "future incoming messages from this client are in the cp1251 character set." It also indicates the character set that the server should use to send the results back to the client. (For example, it indicates which character should be used for column values ​​if you use the SELECT statement.)

The last thing latin1 has far fewer characters available than utf8. For anything other than Western European languages, you will lose data.

For example, if the test column is latin1. The first entry will appear correctly (French accent is in Latin); however, the second Korean entry will appear as question marks.

 SET NAMES 'utf8'; INSERT INTO TESTME(test) VALUES ('Bienvenue sur WikipΓ©dia'); INSERT INTO TESTME(test) VALUES ('ν•œκ΅­μ–΄ μœ„ν‚€λ°±κ³Όμ— μ˜€μ‹  것을 ν™˜μ˜ν•©λ‹ˆλ‹€!'); 
+2
source

All Articles