Migrating old 3.23.49 MySQL database to 5.0.51 MySQL database - Encoding in ANSI and UTF-8

I want to transfer MySQL database 3.23.49 to MySQL 5.0.51 database. Now I have exported the SQL file and I am ready to import. I looked in the sql file, and Notepad ++ shows me that the files are encoded in ANSI. I looked at the values, and some of them are in ANSI, and some of them are in UTF-8. What is the best way to continue?

  • Should I change the encoding in Notepad ++?
  • Should I use ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8; ?
  • Should I use iconv?
  • Should I look at each table and make the necessary changes?
  • Whate - settings for import? MYSQL323 compatibility mode and latin1 encoding?
  • Do I have to know something if php scripts use a different encoding?

Thanks for the tips!

+4
source share
2 answers

I converted the MySQL 4.0 database (which did not yet have the concept of character encoding) to MySQL 5.0 four years ago, therefore BTDT.

But above all, there is no ANSI character encoding ; this is a fallacy and misunderstanding that appeared from earlier versions of Windows (there are ANSI escape sequences , but they have nothing to do with character encoding). You are certainly looking at Windows-1252- encoded text. You should convert this text to UTF-8, since then you have a better chance to keep all used characters intact (UTF-8 - Unicode encoding and Unicode contains all characters that can be encoded using Windows-125x, but in different code points).

I used the iconv and recode programs (on a Debian GNU / Linux system running the MySQL server) to convert the MySQL export text (created by phpMyAdmin) from Windows-1252 (created by phpMyAdmin) to UTF -8. Use any program or combination of programs that works best for you.

Regarding your questions:

  • You can try, but it may not work. In particular, there may be a problem opening a large database dump using Notepad ++ or another text editor.
  • It depends. ALTER TABLE … CONVERT TO … does more than just convert encodings.
  • See paragraph above.
  • Yes. You must set the character encoding for each table and each text field into which you are importing data into utf8 (use any utf8_… sorting that matches your purpose or the best data). ALTER TABLE … CONVERT TO … does this. (But see 2.)
  • I do not think MYSQL323 matters here, since your export will only contain CREATE , INSERT and ALTER expressions. But first check the manual (the "?" Icon next to the setting in phpMyAdmin). latin1 means β€œWindows-1252” in MySQL 5.0 , so this might work, and you should skip the manual import conversion.
  • I do not think so; PHP does not yet support Unicode . The important thing is how the data is processed using a PHP script. Typically, the Content-Type header field for your generated text resources using this data should end in ; charset=UTF-8 ; charset=UTF-8 .

In addition, you should no longer use MySQL 5.0.x. The current stable version of MySQL is 5.5.18 . β€œIn accordance with the MySQL support lifecycle policy, active support for MySQL 5.0 was completed on December 31, 2009. MySQL 5.0 is now in the extended support phase. ” MySQL 5.0.0 Alpha, released 2003-12-22, Extended support is expected will end 8 years later, in 2011-12-31 (this year) .

+3
source

If the problem is to import a mysql utf8 encoded dump, the solution usually adds --default-character-set=utf8 to the mysql parameters:

 mysql --default-character-set=utf8 -Ddbname -uuser -p < dump.sql 

UPD1: if the dump file is damaged, I will try to export the database again from the table so that the dump will result in the correct file encoded in utf8.

+5
source

Source: https://habr.com/ru/post/1381710/


All Articles