Introduction
How do I change the default Character set within MySQL/MariaDB to utf8?
Procedure
In order to set change the default character set within MySQL/MariaDB follow the steps below:
Open the MySQL configuration file at /etc/my.cnf:
vi /etc/my.cnf
Under the [client] section, add the following entry:
default-character-set=utf8
Under [mysqld] add:
default-character-set=utf8 init_connect=’SET NAMES utf8′
Once complete, you'll need to issue a restart to the MySQL server:
/scripts/restartsrv_mysql
If you would like to validate that the changes have been applied, you may pass the following command via MySQL CLI:
show variables like ‘char%';
Please note that existing databases are not affected unless you alter their character sets. You can review MySQL documentation on this topic for more information on how this works:
MySQL :: MySQL 5.6 Reference Manual :: 10.5 Character Set Configuration
MySQL :: MySQL 5.6 Reference Manual :: 10.1.3.3 Database Character Set and Collation
MariaDB also provides a useful document on setting the character set for your databases:
Setting Character Sets and Collations
Comments
0 comments
Article is closed for comments.