Found the following from the web: $sudo gedit /etc/mysql/my.cnf
Under [client] add.
default-character-set=utf8
Under [mysqld] add.
default-character-set=utf8
Then save and exit
$ /etc/init.d/mysql restart
The result appears:
Since the script you are attempting to invoke has been converted to an Upstart job, you may also use the stop(8) and then start(8) utilities, e.g. stop mysql ; start mysql. The restart(8) utility is also available. start: Job failed to start
It may be a version problem, check the method of modifying the character encoding method for versions after 5.5, and found that the method of modifying [mysqld] has changed to
[mysqld] added under should read.
character-set-server=utf8
collation-server=utf8_general_ci
save and quit
$ /etc/init.d/mysql restart
success
To access the MySQL console.
show variables like 'character%';
+———————————–+———————————–+
| 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)