Home>Article>Operation and Maintenance> How to modify the mysql character set under linux

How to modify the mysql character set under linux

青灯夜游
青灯夜游 Original
2022-01-04 15:50:58 4996browse

Modification method: 1. Open and edit the "my.cnf" file; 2. Configure "default-character-set", "default-storage-engine", "character-set-server" and other items value; 3. Save the changes and restart the service.

How to modify the mysql character set under linux

The operating environment of this tutorial: linux5.9.8 system, mysql8 version, Dell G3 computer.

View MySQL character set

Log in to mysql:

mysql -u root -p

Query mysql character set:

mysql> show variables like 'chara%';

Description: Set the character_set_server character set to UTF-8.

Method to modify the mysql character set:Set the MySQL character set to UTF-8 by modifying the configuration file

1. Copy the my-default.cnf configuration file to / in the my.cnf file under etc.

cp /usr/share/mysql/my-default.cnf /etc/my.cnf

Note: Global information is configured in the etc folder. If my.cnf exists under etc, you can skip this step. If it does not exist, copy my-default.cnf to etc and name it my.cnf.

2. Go to the etc directory to open the my.cnf file and modify my.cnf. The modification content is as follows.

Edit my.cnf file

vi my.cnf

Add the following two sentences above [mysqld]

[client] default-character-set=utf8

Add the following sentences at the bottom of [mysqld]#

default-storage-engine=INNODB character-set-server=utf8 collation-server=utf8_general_ci

4. Log in to MySQL again and check whether the character set has been modified.

##                

Related recommendations:

mysql video tutorial

, "

Linux tutorial

"

The above is the detailed content of How to modify the mysql character set under linux. 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