MySQL设置UTF-8编码格式步骤
--------------------------------------------------------------------------------------------------------------------
1. MySQL Start.bat(cmd启动MySQL数据库)免密码登录
-- 设置编码:set names gbk;
mysql --default-character-set=gbk -uroot -proot
---------------------------------------------------------------------------------------------------------------------
2. MysSQL安装路径里的my.ini文件设置以下字段
[mysqld]
datadir=C:/Program Files/MariaDB 10.3/data
port=3306
innodb_buffer_pool_size=1998M
character-set-server=utf8
[client]
port=3306
plugin-dir=C:/Program Files/MariaDB 10.3/lib/plugin
default-character-set=gbk
--------------------------------------------------------------------------------------------------------------------
3. 查看MySQL数据库使用的编码:
show variables like 'char%';
--------------------------------------------------------------------------------------------------------------------
4. 更改MySQL数据库编码
set character_set_client = utf8';
set character_set_connection = utf8';
set character_set_database = utf8';
set character_set_server = utf8';
set character_set_system= utf8';
--------------------------------------------------------------------------------------------------------------------
5. 重启MySQL服务
--------------------------------------------------------------------------------------------------------------------