Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to change the default encoding of mysql to UTF8

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to change the default coding of mysql to UTF8, which is very detailed and has a certain reference value. Friends who are interested must finish it!

How to change the default encoding of mysql to UTF8: first, add [default-character-set=utf8] in the client field; then add [character-set-server=utf8] in the mysqld field; finally, restart the mysql service.

How to change the default encoding of mysql to UTF8:

Windows:

A. WIN+R net stop mysql shuts down the mysql service

b. Copy my-dafault.ini, rename it to my.ini, and enter it

UBUNTU:

* * sudo vim / etc/mysql/my.cnf * * enter

Do the following:

1. Add default-character-set=utf8 in the "client" field, as follows:

[client] port = 3306socket = / var/lib/mysql/mysql.sockdefault-character-set=utf8

2. Add character-set-server=utf8 in the "mysqld" field, as follows:

[mysqld] port = 3306socket = / var/lib/mysql/mysql.sockcharacter-set-server=utf8

3. Add default-character-set=utf8 in the "mysql" field, as follows:

[mysql] no-auto-rehashdefault-character-set=utf8

After the modification is completed, the service mysql restart restarts the mysql service. Note: the [mysqld] field is different from the [mysql] field. No one has reported this on the Internet.

Note: show variables like 'character%' can view the mysql encoding method. After modification, it is as follows:

+-- +-- + | Variable_name | Value | +-- +-- + | character _ set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | character_set_results | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | / usr/share/mysql/charsets/ | +-- -+ above is how to change the default encoding of mysql to all the contents of UTF8 Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report