我有一个配置:
'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无法连接到数据库。 无法建立到数据库的连接:拒绝用户'root'@'localhost‘的SQLSTATEHY000访问(使用密码: YES)
我怎么才能修好它?我正通过MySql工作台与这个登录和密码连接得很好。是什么阻止Cake框架做同样的事情呢?
发布于 2015-05-06 15:59:03
您是否加载了使您能够在配置中连接到MYSQL的模块。基本上,您需要确保您的php.ini有下面一行注释的extension=php_mysql.dll extension=php_mysqli.dll
发布于 2015-05-11 10:53:47
当用户名或密码不正确时,通常会显示此错误消息。
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中,默认root密码为空。
https://stackoverflow.com/questions/30081689
复制相似问题