Find configuration file
I installed it through sudo apt-get install MySQL. MySQL configuration file in/etc/mysql/my.cnf
If this file is not found, you can run sudo find/-iname ' *.cnf ' to locate all CNF files
Modify configuration file
Add under [mysqld]
Default-character-set=utf8
Add under [client]
Default-character-set=utf8
Restart MySQL
sudo service MySQL restart
Log in to MySQL to see if it's successful
# mysql-u Root
Mysql> show VARIABLES like ' char% ';
+--------------------------+----------------------------+
| variable_name | VALUE |
+--------------------------+----------------------------+
| character_set_client | UTF8 |
| character_set_connection | UTF8 |
| Character_set_database | UTF8 |
| Character_set_filesystem | BINARY |
| Character_set_results | UTF8 |
| Character_set_server | UTF8 |
| Character_set_system | UTF8 |
| Character_sets_dir | /usr/share/mysql/charsets/|
+--------------------------+----------------------------+
8 ROWS in SET (0.00 sec)
Restart MySQL
Depending on how you install MySQL, use the unused commands to reboot your MySQL. If you have configured to use the Mysqld self-boot method, you can perform
#/etc/rc.d/init.d/mysql Restart
to reboot.
Or if you configure MySQL as a system service, you can perform
# service MySQL Restert