How to change Default character set in MySQL with command line?

kumkumsharma

Administrator
Staff member
If you want to change default character set in Mysql then first you have to open my.cnf file with below command:

Code:
vi /etc/my.cnf
in this file you have to add below line:

Code:
default-character-set=utf8
Under [mysqld] add below lines too:

Code:
default-character-set=utf8
init_connect=’SET NAMES utf8′
Now to reflect changes in your my.cnf file you have to restart mysql with below command:

Code:
/scripts/restartsrv_mysql
You can validate changes with below command :

Code:
show variables like ‘char%';
 
Top