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 set the mysql5.7 code set to utf8mb4

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to set the mysql5.7 code set to utf8mb4, the article introduces in great detail, has a certain reference value, interested friends must read it!

1. Check your current database version

Use the command: select version ()

If you find that the current database version is prior to 5.5.3, you need to reinstall the database, and if you skip steps 2 and 3 after that version.

2. Back up the data in the current database

The database visualization software I use here is navicat, right-click the corresponding database under the database, then select "dump SQL file", select "data and structure", export the database file with the suffix .sql and save it to the hard disk. When the new database version is installed, select the database, right-click "run SQL file" so that the data will not be lost.

3. Delete the current database completely

The deletion of the database is very tedious, sometimes the deletion is not clean, I refer to some methods here, personal testing is available.

3.1Delete Mysql's service

Control Panel-"all Control Panel items -" programs and features, uninstall mysql server!

Delete all files in the mysql directory

Delete the my.ini file and all files under the mysql folder

The general installation directory is: C:\ Program Files\ MySQL

3.3 Delete registry information

Press "win" + R at the same time and enter regedit to enter the registry manager

Delete:

HKEY_LOCAL_MACHINE\ SYSTEM\ ControlSet001\ Services\ Eventlog\ Application\ MySQL folder

Delete:

HKEY_LOCAL_MACHINE\ SYSTEM\ ControlSet002\ Services\ Eventlog\ Application\ MySQL folder.

Delete:

Folder for HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Services\ Eventlog\ Application\ MySQL

If you don't have or don't exist, you don't have to worry about it.

3.4 Delete hidden mysql folders

It usually exists in a hidden form. Searching the directory under disk C should find C:\ ProgramData\ MySQL\ MySQL Server 5.7.

4 install database mysql5.7

First download mysql5.7, I use the msi version, the installation process will not be described in detail, in short, the final installation to the default path, that is, disk C, after installation, in order to call up the small black window, I configured the system environment variables

Select path in the system variable, and enter the installation path of the database under path. Just go to the path of the bin folder, and then call up a small black window to view your own coding format.

The statement is: SHOW VARIABLES LIKE 'character_set%'

Utf-8 should all be displayed, because the default for installation is utf-8.

5 modify the coding format

The first step is to modify the configuration in the configuration file (my.ini), but we found that this file is not in the installation directory.

This is what annoyed me all afternoon. Later, after consulting the data, I found that the file was hidden in the hidden folder on disk C, or searched for C:\ ProgramData\ MySQL\ MySQL Server 5.7under disk C.

The file was found:

Make configuration changes under the my.ini file

[client] default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4 [mysqld] character-set-client-handshake = FALSE character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci init_connect='SET NAMES utf8mb4'

Note that the above two bold entries are in the original file configuration, and the values are both utf-8, so be sure to replace the original ones when adding these two entries, otherwise mysql cannot read the configuration file and the service cannot start.

Save after modification, and then restart the database service. The address of the restart service is as follows.

Then type two more character set commands in the small black window to verify it.

SHOW VARIABLES LIKE 'character_set%'

The character set of the database has been modified.

SHOW VARIABLES LIKE 'collation%'

The character set of the data table has also been modified.

It is worth noting that utf8mb4 is compatible with utf-8, so you don't have to worry about garbled data.

The above is all the content of the article "how to set the mysql5.7 code set to utf8mb4". 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