当连接到mySQL时出现此错误:服务器向客户端发送了未知的字符集

时间:2019-02-20 15:34:43

标签: php mysql wamp bitnami

连接到mySQL时,出现此错误:服务器向客户端发送了未知的字符集。Error on my local host

因此,在数据库连接文件中会发生此问题,该文件的代码如下所示:

<?php
// Set up the database connection
//Revisit upon later implementation

$dsn = 'mysql:host=localhost;dbname=resumesite;charset=UTF8;';
$username = 'ddunevant';
$password = 'WoShiHenHao1!';
$options = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);

try {
        //$db = new mysqli('127.0.0.1', $username, $password, 'test');
    $db = new PDO($dsn, $username, $password, $options);
} catch (PDOException $e) {
    $error_message = $e->getMessage();
    include('errors/db_error_connect.php');
    exit();
}
?>

但是,我在线上查看了很多内容,说问题出在MySQL的配置文件中。这篇文章以这种方式回答了我的问题:PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers

但是我已经尝试过此方法以及其他许多类似方法。使我的情况与他们的情况不同的一件事是,我使用的是Bitnami Wampstack。我已将my.ini更改为以下内容。

[client]
default-character-set=UTF8

[mysqladmin]
user=root
port=3307

# The MySQL server
[mysqld]
# set basedir to your installation path
basedir="C:/Bitnami/wampstack-5.6.40-0/mysql"
# set datadir to the location of your data directory
datadir="C:/Bitnami/wampstack-5.6.40-0/mysql/data"
port=3307
character-set-server=UTF8
collation-server=utf8_unicode_ci
max_allowed_packet=32M
bind-address=127.0.0.1
# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB

log-error="C:/Bitnami/wampstack-5.6.40-0/mysql/data/mysqld.log"
[mysqldump]
max_allowed_packet=32M

[mysql]
port=3307

如您所见,我正在将归类服务器更改为正确的归类集“ collat​​ion-server = utf8_unicode_ci”。我该怎么办才能解决此问题?

0 个答案:

没有答案