Database

Change MySQL Database Collation and Character Set

This article is about to explain how you can manage database collation and character set of your database. If you are working on website which covers only one language which is english then you may not worry about these stuff.

But If you are dealing with the multilinguag website which includes various languages (chinese, hindi, gujarati, etc.) then you MUST need to take care of this stuff.

To make your database able to handle these characters of different languages you need to set proper Database Collation and Character Set for the database.

Change MySQL Database Collation

Before set the proper Database Collation you may like to get the List of MySQL Database Collation. Execute below query to get the list of all available Database Collation.

[cc lang=”mysql”]
SHOW COLLATION;
[/cc]

You can select any Database Collation which arrived from above query.
Now to change the Database Collation you need to perform below query to change it.

[cc lang=”mysql”]
ALTER SCHEMA `schema_name` DEFAULT COLLATE collation_name_here ;
[/cc]

Note: To make your database able to handle these characters of different languages you need to set proper Database Collation and Character Set for the database.

Change MySQL Database Character Set

Same as Database Collation you can get the list of Character Set using below query.

[cc lang=”mysql”]
SHOW CHARACTER SET;
[/cc]

Now to change the Database Character Set you need to execure below query.

[cc lang=”mysql”]
ALTER SCHEMA `schema_name` DEFAULT CHARACTER SET character_set_name;
[/cc]

Conclusion

With this article you will come to know about how to set the Database Collation and Character Set in MySQL. This will be useful when you are facing a problem related to different language characters.

Next I will post the article about storing unicode characters in database. So subscribe to our feed with your email address.

Shares:

Leave a Reply

Your email address will not be published. Required fields are marked *