Wednesday, 25 July 2018

MySQL: How to change default Character set to UTF-8

In the previous post, I discussed and provided the small note on Database Character Set and Collation.
In this post, I am showing how you can configure or change default Character Set in MySQL?
Sometimes, it requires changing the default character set of MySQL Server or MySQL Database.
A Character set “latin1” and Collation “latin1_swedish_ci” are the default of MySQL Server.
This is a standard configuration, and you do not need to change anything, but if your application requires storing data using a different character set, you have to change this default configuration.
Here, I am showing how to change your default character set and collation to UTF-8.
MySQL Server provides, different three ways to configure character set and collation.
  • Configure Character set and Collation at Database Level.
  • Configure Character set and Collation at Server Startup.
  • Configure Character set and Collation during MySQL Server Installation and Configuration.
First, check your default Character Set and Collation of MySQL Server.
If you want to change the default to UTF-8, you want to add the following to my.cnf (MySQL Configuration File).
Specify Character Settings per Database:

0 comments:

Post a Comment