Home > Database > Mysql Tutorial > body text

How to modify mysql encoding in ubuntu

WBOY
Release: 2022-05-27 17:07:33
Original
3103 people have browsed it

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
Copy after login

View encoding:

show variables like 'char%';
Copy after login

How to modify mysql encoding in ubuntu

2. Modify the mysqld.cnf file

sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
Copy after login

Add a line to the file:

character-set-server=utf8
Copy after login

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
Copy after login

Add a line under [mysql]:

default-character-set=utf8
Copy after login

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
Copy after login

5. Check the encoding

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template