Home  >  Article  >  Database  >  How to modify mysql encoding in ubuntu

How to modify mysql encoding in ubuntu

WBOY
WBOYOriginal
2022-05-27 17:07:333091browse

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.

How to modify mysql encoding in ubuntu

The operating environment of this tutorial: Ubuntu 16.04 system, mysql8.0.22 version, Dell G3 computer.

How to modify mysql encoding in ubuntu

1. View the current encoding

Log in to the database:

mysql -u root -p

View encoding:

show variables like 'char%';

How to modify mysql encoding in ubuntu

2. Modify the mysqld.cnf file

sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

Add a line to the file:

character-set-server=utf8

The file is as shown:
How to modify mysql encoding in ubuntu
Save the file and exit.

3. Modify the mysql.cnf file

sudo vim /etc/mysql/conf.d/mysql.cnf

Add a line under [mysql]:

default-character-set=utf8

The file is as shown:

How to modify mysql encoding in ubuntu

4. Restart the database

Restart the database to make the new configuration take effect:

service mysql restart

5. Check the encoding

mysql -u root -p
show variables like 'char%';

Modification successful.
How to modify mysql encoding in ubuntu

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn