Skip to content

Instantly share code, notes, and snippets.

@amolkhanorkar
Created March 12, 2014 06:05
Show Gist options
  • Save amolkhanorkar/9501725 to your computer and use it in GitHub Desktop.
Save amolkhanorkar/9501725 to your computer and use it in GitHub Desktop.
Change MySQL Collation
Change MySQL Collation
On ubuntu when we install the mysql it takes the default database character set as swidish.
But we need the character set as UTF-8.
Read this article for more details : http://dev.mysql.com/tech-resources/articles/4.1/unicode.html
Also read this article for more information about storing the data in Indian launguages in your mysql database,
http://mrothouse.wordpress.com/2006/09/18/mysql-database-character-set/
Please follow the following steps to change the character set of your mysql database,
1) You have to edit your mysql setting file "my.cnf" located in /etc/mysql/ folder
2) Add the following settings in that file,
Add the lines in ,
[client]
default-character-set=utf8
[mysqld]
socket = mysql
skip-locking
init_connect='SET collation_connection = utf8_general_ci'
init_connect='SET NAMES utf8'
default-character-set=utf8
character-set-server = utf8
collation-server = utf8_general_ci
[mysql]
default-character-set=utf8
Now save the file & restart the mysql. ( sudo /etc/init.d/mysql restart)
Then please check the database collation from the terminal by following command,
(You can also interact with mysql from the command line)
1) mysql -h 127.0.0.1 -u root -p after this it asks for your mysql password. Provide that password & it will then continue with the mysql prompt.
2) fire "status" command. It will give you the basic configuration information of the mysql.
Please install the mysql query browser by following the instructions from the link,
http://www.zolved.com/synapse/view_content/27986/How_to_install_MySQL_On_Ubuntu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment