mysq version: 5.7.21
Operating system: Linux (Ubuntu)
The basic idea of the whole operation is as follows (including the solution idea of the problem, you can see the final command summary first if you want to solve the problem directly)
Check MySQL code
Locate the MySQL configuration file
Modifying a configuration file
Restart MySQL service
1. Check MySQL code
In the MySQL console input:show variables like ' character_set_% '; if not, then you need to modify the MySQL code.
2. Locate the MySQL configuration file
The configuration file for Ubuntu under MySQL is /etc/mysql/my.cnf
In fact, Linux can use the following command to find the configuration file
Find/-iname *.cnf-print
But we found that there were only two words.
!includedir/etc/mysql/conf.d/
!includedir/etc/mysql/mysql.conf.d/
that's not exactly what we're thinking. Yes, I guess it's 5.7. The configuration file is split and the configuration of different responsibilities is stored separately (not sure if you understand the right)
So we put the files here in the two configuration folder open separately, we found
/etc/mysql/mysql.conf.d/mysqld.cnf The most configuration content, it seems that we need to find.
3. Modify the configuration file
Because the mysql5.7 version is a bit new, some of the configuration on the web is a bit less believable, but we can find the answer in the MySQL website's documentation.
Official documents:https://dev.mysql.com/doc/refman/5.7/en/
We can see a bunch of documents about character sets, with a configuring application character set and collaion, and I think that's what we need.
One of these words, I think we should write this configuration to our configuration file.
4 restart MySQL service
Service MySQL Restart
re-enter MySQL view and you will find that your MySQL code is already configured
Command Summary:
1 Viewing character sets: Show variables like ' character_set_% '
2 modifying configuration: sudo gedit/etc/mysql/mysql.conf.d/mysqld.cnf
3 add under [Mysqld]:
Character-set-server=utf8
Collation-server=utf8_general_ci
4 restart Mysql:service mysql restart
Linux (Ubuntu) uses journaling------settings for MySQL encoding (utf-8)