Changing MySQL Database Character Set

Oct 28th, 2008 | By admin | Category: Mysql

You have probably come across with the mysql character set problem, If you are trying to implement a database in a language other than English. You are inserting rows with your text in your language, but you see invalid characters on your database, phpmyadmin mostly.

This is mostly because of character set defined in your mysql database is not proper for your language. This is usually UTF-8 Unicode, and it is default.

Fix:

Changing the charecter set can be done via mysql command line.  Just login to your server via SSH and bring your mysql command line on with following command.

 mysql -h   -D   -u   -p

Now it will ask you password before giving access to mysql prompt.

ALTER DATABASE wowebmaster DEFAULT CHARACTER SET utf8 COLLATE utf8_turkish_ci \g

When you get access to mysql command line, type the above mysql command, it will change the character set of wowebmaster database to utf8_turkish_ci . That’s it. Replace the database name and the character set for your own modifications.

Update: Changing Table Character Set

If you are looking for changing your table’s character set, you can use the following command;

ALTER TABLE table_name DEFAULT CHARACTER SET utf8 COLLATE utf8_turkish_ci \g
  • Share/Save/Bookmark
Tags: , ,

Leave Comment