gpt4 book ai didi

php - 使用 CakePHP 时无法连接到本地 MySQL 数据库

转载 作者:行者123 更新时间:2023-11-30 22:44:22 25 4
gpt4 key购买 nike

我有这个配置:

'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
/**
* CakePHP will use the default DB port based on the driver selected
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
* the following line and set the port accordingly
*/
//'port' => 'nonstandard_port_number',
'username' => 'root',
'password' => 'root',
'database' => 'addressbook',
'encoding' => 'utf8',
'timezone' => 'UTC',
'cacheMetadata' => true,

/**
* Set identifier quoting to true if you are using reserved words or
* special characters in your table or column names. Enabling this
* setting will result in queries built using the Query Builder having
* identifiers quoted when creating SQL. It should be noted that this
* decreases performance because each query needs to be traversed and
* manipulated before being executed.
*/
'quoteIdentifiers' => false,

/**
* During development, if using MySQL < 5.6, uncommenting the
* following line could boost the speed at which schema metadata is
* fetched from the database. It can also be set directly with the
* mysql configuration directive 'innodb_stats_on_metadata = 0'
* which is the recommended value in production environments
*/
//'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
],

我有一个本地 MySql 数据库,其登录参数与我在上面输入的相同,但在新安装的 CakePHP 的首页上,接下来告诉我:

CakePHP is NOT able to connect to the database.

Connection to database could not be established: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)

我该如何解决?我通过 MySql Workbench 使用此登录名和密码连接得很好。是什么阻止了 Cake 框架做同样的事情?

最佳答案

您是否在您的配置中加载了使您能够连接到 MYSQL 的模块。基本上你需要确保你的 php.ini 有以下行注释扩展=php_mysql.dllextension=php_mysqli.dll

关于php - 使用 CakePHP 时无法连接到本地 MySQL 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30081689/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com