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

How to modify the mysql character set under linux

青灯夜游
Release: 2022-02-22 11:22:24
Original
5159 people have browsed it

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

Query mysql character set:

mysql> show variables like 'chara%';
Copy after login

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

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

Add the following two sentences above [mysqld]

  [client]  
  default-character-set=utf8
Copy after login

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

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

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!

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