installation

Importing a UTF-8 database and keep special characters

This is a follow up to the post "Creating a UTF-8 database to work with special characters".

When you want to move your database from one server/database to another one, you generally create a sql dump file from the source database using the mysqldump command and then do an import into the destination using the mysql source statement or via shell redirection (<).

This is just a heads up. When you make the connection on the destination server/database, specify the --default-character-set=utf8 option.

You end up with something like:

mysql -u user -ppassword --default-character-set=utf8 database < "dump.sql"

Creating a UTF-8 database to work with special characters

I'm a Dutch speaking person. So sometimes I have to make Dutch websites. The Dutch language uses some special characters that are not used in English. I'm talking about tremas, umlauts, ... (ë, â, ...). These characters can turn up weird on your website.

As soon as you start seeing those appearing on your website, you might be sure it has to do with character sets and encoding.

And since your website is build upon a database, your database should be the first thing too look at finding the cause of your problem.

So the first thing I do when creating my database is to make sure it uses the correct character set. In MySQL this is done by issuing the following statement:

CREATE DATABASE my_database character SET utf8 COLLATE utf8_general_ci;

Syndicate content