php连接mysql8.0的时候,页面的中文变成了问号

  1. 查看数据库的编码
    show create database <数据库名>;
  2. 查看数据表的编码
    show create table <表名>;
  3. 查看数据库的编码格式
    mysql>status
    关于PHP连接MySQL中文出现问号
    修改my.cnf 文件
    vim /etc/my.cnf

在my.cnf文件添加以下内容
[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
init_connect=‘SET collation_connection = utf8_unicode_ci’
init_connect=‘SET NAMES utf8’
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake

然后重启MySQL
systemctl restart mysqld

查看mysql的状态
mysql>status
关于PHP连接MySQL中文出现问号

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2021-05-01
  • 2021-07-06
  • 2022-12-23
  • 2022-01-08
猜你喜欢
  • 2021-05-18
  • 2022-12-23
  • 2021-12-22
  • 2021-11-29
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
相关资源
相似解决方案