CakePhp 3.0:PDO 问题
CakePhp 3.0 : PDO issues
我目前正在使用 CakePHP 3.0,但在连接到我的数据库时遇到问题。
继续:
Your version of PHP is 5.4.16 or higher.
Your version of PHP has the mbstring extension loaded.
Your version of PHP has the openssl extension loaded.
Your version of PHP has the intl extension loaded.
然后:
Your tmp directory is writable.
Your logs directory is writable.
The FileEngine is being used for core caching. To change the config
edit config/app.php
但是:
CakePHP is NOT able to connect to the database.
Connection to database could not be established: SQLSTATE[HY000]
[2006] MySQL server has gone away
我收到的警告是:
Warning (2): PDO::__construct(): MySQL server has gone away
[CORE\src\Database\Driver\PDODriverTrait.php, line 48] Warning (2):
PDO::__construct() [pdo.construct]: Error while reading greeting
packet. PID=25748 [CORE\src\Database\Driver\PDODriverTrait.php, line
48]
我在第 48 行的 PDODriverTrait.php 是:
protected function _connect($dsn, array $config)
{
$connection = new PDO(
$dsn,
$config['username'],
$config['password'],
$config['flags']
);
$this->connection($connection);
return true;
}
我的 app.php 数据源是:
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
'port' => '81',
'username' => 'root',
'password' => '',
'database' => 'projetatelier',
'encoding' => 'utf8',
'timezone' => 'UTC',
'cacheMetadata' => true,
'quoteIdentifiers' => false,
我检查了我的 PDO 扩展,一切似乎都是正确的。
谢谢
根据您显示的代码,问题是:-
您的 MySQL 是否正在其他端口上工作,因此只需将该端口号输入您的 app.php.
或者端口号需要从文件中删除 app.php.
先尝试去掉再试试。如果不工作,则检查哪个端口 MySQL 正在工作,然后将此值放在端口而不是 80.
我目前正在使用 CakePHP 3.0,但在连接到我的数据库时遇到问题。
继续:
Your version of PHP is 5.4.16 or higher.
Your version of PHP has the mbstring extension loaded.
Your version of PHP has the openssl extension loaded.
Your version of PHP has the intl extension loaded.
然后:
Your tmp directory is writable.
Your logs directory is writable.
The FileEngine is being used for core caching. To change the config edit config/app.php
但是:
CakePHP is NOT able to connect to the database.
Connection to database could not be established: SQLSTATE[HY000] [2006] MySQL server has gone away
我收到的警告是:
Warning (2): PDO::__construct(): MySQL server has gone away [CORE\src\Database\Driver\PDODriverTrait.php, line 48] Warning (2): PDO::__construct() [pdo.construct]: Error while reading greeting packet. PID=25748 [CORE\src\Database\Driver\PDODriverTrait.php, line 48]
我在第 48 行的 PDODriverTrait.php 是:
protected function _connect($dsn, array $config)
{
$connection = new PDO(
$dsn,
$config['username'],
$config['password'],
$config['flags']
);
$this->connection($connection);
return true;
}
我的 app.php 数据源是:
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
'port' => '81',
'username' => 'root',
'password' => '',
'database' => 'projetatelier',
'encoding' => 'utf8',
'timezone' => 'UTC',
'cacheMetadata' => true,
'quoteIdentifiers' => false,
我检查了我的 PDO 扩展,一切似乎都是正确的。
谢谢
根据您显示的代码,问题是:-
您的 MySQL 是否正在其他端口上工作,因此只需将该端口号输入您的 app.php.
或者端口号需要从文件中删除 app.php.
先尝试去掉再试试。如果不工作,则检查哪个端口 MySQL 正在工作,然后将此值放在端口而不是 80.