Method: 1. Modify the "mysqld.cnf" file and add "character-set-server=encoding" under mysqld; 2. Add "default-character-set=encoding" under mysql in the file ;3. Restart the mysql database to make the configuration take effect.
The operating environment of this tutorial: Ubuntu 16.04 system, mysql8.0.22 version, Dell G3 computer.
Log in to the database:
mysql -u root -p
View encoding:
show variables like 'char%';
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
Add a line to the file:
character-set-server=utf8
The file is as shown:
Save the file and exit.
sudo vim /etc/mysql/conf.d/mysql.cnf
Add a line under [mysql]:
default-character-set=utf8
The file is as shown:
Restart the database to make the new configuration take effect:
service mysql restart
mysql -u root -p show variables like 'char%';
Modification successful.
Recommended learning: mysql video tutorial
The above is the detailed content of How to modify mysql encoding in ubuntu. For more information, please follow other related articles on the PHP Chinese website!