问题描述
前后端用的UTF8,前后端正常,navicat.exe编辑链接->高级->选择UTF8也不乱码,但是选择自动就乱码。
现在我们后台那边也乱码,所以我怀疑自动编码就是mysql默认编码。
我 vi /etc/my.cnf 设置了编码也没用。最后试着修改了数据库的编码,搞好了
最终解决:右键数据库->编辑数据库->字符集(latin1) && 排序规则(latin1_swedish_ci)
解决过程如下
vi /etc/my.cnf
指定配置路径启动
mysqld --defaults-file=/etc/my.cnf --user=root
service mysql restart
service mysqld start
mysql -u root -p
show variables like '%char%';
set global character_set_client=latin1;
set global character_set_connection=latin1;
set global character_set_database=latin1;
set global character_set_results=latin1;
set global character_set_server=latin1;
彻底解决mysql中文乱码
https://blog.csdn.net/u012410733/article/details/61619656
最终解决
linux终端
mysql> show variables like '%char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
navicat.exe - 命令列界面
mysql> show variables like '%char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)
右键数据库->编辑数据库->字符集(latin1) && 排序规则(latin1_swedish_ci)