Forum Moderators: open

Message Too Old, No Replies

MYSQL, database migration, charsets

Going from MYSQL 4.1 to 4.0.25

         

davelms

5:49 pm on Jun 19, 2007 (gmt 0)

10+ Year Member



I have a current database, MYSQL 4.1, and tables are UTF8.

Moving to MYSQL 4.0.25 (yes, *backwards* in version terms) and likely charset will therefore be LATIN1.

Anyone done this before? I've read through a variety of forums, and upgrade techniques, but essentially I am going backwards in version terms. When I do dummy runs of the migration, export/import using mysqldump/mysql command lines respectively, certain characters are not being inserted consistently.

Just need some pointers really for how to approach this.

I appreciate this is an unusual migration.

davelms

6:04 pm on Jun 28, 2007 (gmt 0)

10+ Year Member



Ok, so no one knew, so for the benefit of anyone that reads this and wonders what to do (or how I did it)...

In the end I...

1) ... created a copy of the structure of my MYSQL 4.1 database, using phpmyadmin.

2) altered my cloned MYSQL 4.1 database tables to latin1 from utf-8...

ALTER TABLE mytable CONVERT TO CHARACTER SET latin1 COLLATE latin1_general_ci;

3) copied over the data from my existing MYSQL 4.1 database to my cloned MYSQL 4.1 database, using phpmyadmin (which does a INSERT ... SELECT)

4) used mysqldump to dump the data from the cloned MYSQL 4.1 database. Now here's the key point, which took a lot of digging. Regardless of the definitions/structure of your database, mysqldump always creates its dump file as utf-8 by default. So whilst the CREATE TABLE shows latin1 the file of INSERTS is actually utf-8. So you have to override this functionality. Here's what I went with, some of it may be supurfluous...

mysqldump -u[user] -p[password] [database] --skip-opt --create-options --default-character-set=latin1 --compatible=mysql40 > [output file]

5) using a normal mysql command line to load the resultant file's contents into the MYSQL 4.0 database.

Hope this is useful, I saw this problem reported literally hundreds of times and never a solution told, so if this helps just one more person from pulling their hair out...

phranque

12:16 am on Jun 29, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



i was just looking into character set conversion a couple of days ago and found this reference on latin1 to utf8 [oreillynet.com] which has some useful information which could be applied in reverse.