Joyent

Translations of this page:

Import and fix a TextDrive MySQL database

This article deals with the problem described in the Potential fix for database encoding quirkiness forum thread. On Shared Accelerators, the Apache, PHP and MySQL chain is configured for pure UTF8 character set encoding (Rails and other frameworks would likely work that way too, so this is not limited to PHP). On old FreeBSD servers, the MySQL connection character set was set to latin1, which basically mangled all non-ASCII characters on the way in and out, which was fine, but became a problem when moving to a pure UTF8 setup elsewhere.

When importing such database into Shared Accelerators, the UTF8 characters are broken. The known workaround (as guessed correctly by the users in the forum thread) is to create a dump file using LATIN1 character set, change all occurrences of 'latin1' to 'utf8' in the dump file and import as UTF8. This can get tedious with anything but a single database, so here's a script to help:

migdb-1.3.sh.txt

It is intended to run from within your shell on a Shared Accelerator, so download it there, directly:

curl -o migdb.sh http://wiki.joyent.com/_media/shared:kb:migdb-1.3.sh.txt
chmod 700 migdb.sh

Run it without any arguments (./migdb.sh) to see some help. The script will connect to your TextDrive account (assuming you still have it online and accessible) for you, make a dump file, mass edit all places that need to be edited, and import it - as per the arguments passed.

This script is purely experimental and definitely far from perfect. Joyent will not provide any support for the script usage or consequences of running it. We invite everybody to comment on the problem in the forum thread and suggest improvements.

 
shared/kb/mysql-import-fix.txt · Last modified: 2008/02/03 17:29 by alexbcoles
 
Recent changes RSS feed Creative Commons License Driven by DokuWiki