Zhixian's Tech Blog

2010-07-11

Set MySql default collation to UTF8

Filed under: computing, database, web application development — Tags: , , , , , , — Zhixian @ 02:06:07 am

One of the bad thing about installing MySql using Ubuntu Software Center is that it does not allow you to select the default collation of MySql Server. This is one of the nice things you would find in the Windows version of MySql installer.

In any case, to set MySql collation to use UTF8, all you have to do is:

  1. Edit your MySql configuration file (typically found at /etc/mysql/my.cnf)
  2. Under the section [mysqld]add the following lines:
    # utf8
    init-connect=’SET NAMES utf8′
    character-set-server=utf8
    collation-server=utf8_general_ci
  3. Restart your MySql

Create a free website or blog at WordPress.com.