Home  >  Article  >  Database  >  What should I do if mysql reports an error when modifying my.ini?

What should I do if mysql reports an error when modifying my.ini?

coldplay.xixi
coldplay.xixiOriginal
2020-11-03 11:20:182934browse

The solution to the error reported by mysql when modifying my.ini: First change the default encoding of mysql to utf8mb4 and modify the [my.ini] configuration; then modify the variables and check whether the setting is successful.

What should I do if mysql reports an error when modifying my.ini?

##More related free learning recommendations: mysql tutorial(Video)

Solution to the error reported by mysql when modifying my.ini:

The process of changing the default encoding of mysql to utf8mb4 As follows:

  • Close the mysql service

  • Modify the my.ini configuration file (the modification method is written below), be careful to save it as ANSI encoding

  • Start the mysql service

  • Modify the variables, (the setting method is written below)

  • Check whether the setting is successful, (the check method is written below)

Modify my.ini configuration: (You only need to pay attention to the utf8mb4 part of the configuration, and other parts of the configuration No need to refer to mine)

[mysqld] 
character-set-client-handshake = FALSE 
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci 
init_connect='SET NAMES utf8mb4'
sql_mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"
default_storage_engine=innodb
innodb_buffer_pool_size=1000M
innodb_log_file_size=50M
innodb_file_format=barracuda
innodb_file_per_table=true
innodb_large_prefix=true
max_allowed_packet=500M
# 设置mysql的安装目录
basedir=D:\mysql-5.6.40-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\mysql-5.6.40-winx64\data
# 允许最大连接数
max_connections=200
 
[mysql]
default-character-set = utf8mb4
 
[client]
default-character-set = utf8mb4

Modify variable method:

Just execute the following sql

set character_set_client = utf8mb4;
set character_set_connection = utf8mb4;
set character_set_database = utf8mb4;
set character_set_results = utf8mb4;

Check the successful setting method:

Execute sql

SHOW VARIABLES WHERE Variable_name LIKE 'character_set_%' OR Variable_name LIKE 'collation%';

The results are as follows and the result is successful

What should I do if mysql reports an error when modifying my.ini?

The above is the detailed content of What should I do if mysql reports an error when modifying my.ini?. 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