Tuesday, June 29, 2010

Steps to change the character set of a MySQL database to utf8?


Please follow the steps as it is to change the character set to Mysql

1) Dump the data of the mysql database to data_dump.sql

root@server1 [~]# mysqldump -t -u -p >data_dump.sql;

2) Dump the schema of the mysql database to schema_dump.sql

root@server1 [~]# mysqldump -d -u -p >schema_dump.sql

3)Now edit the file schema_dump.sql and remove the entries “DEFAULT CHARSET=”from the table and column definitions.

4) Drop the existing database.
root@server1 [~]#mysqladmin drop

5) Create a new database with uft8 as the default character set:

root@server1 [~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1074337 to server version: 4.1.22-standard


Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql>CREATE DATABASE DEFAULT CHARACTER SET utf8;

Now quit the mysql.

6) Import schema_dump.sql into the new database:

root@server1 [~]# mysql -u -p

7. Import data_dump.sql into the new database:
root@server1 [~]# mysql -u -p


Tags: LAMP, Linux, mysql, techzinformaticha-support, phpmyadmin