1. Log in to the database and view the database character encoding table:
View encoding SQL:
SHOW VARIABLES LIKE'character%';
show variables like'char%';
2. Exit the database, modify the mysql configuration file, and change the character encoding of the database:
vi /etc/my.cnf
3. After entering the configuration file, add the following code, then save and exit
default-character-set=utf8
character-set-server=utf8
collation-server=utf8_unicode_ci
4. Restart the database service, log in to the database: systemctl restart mysql.service
Note:
start mysql command: service mysql start
stop mysql command: service mysql stop
view mysql status: service mysql status
restart mysql: service mysql restart
5. Check the coding table again to confirm that the modification is complete:
SHOW VARIABLES LIKE'character%';