![](/img/trans.png)
[英]Can't connect mobile device to local MySQL database, but works using emulator
[英]Can't connect to local MySQL database while using CakePHP
我有这个配置:
'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无法连接到数据库。
无法建立与数据库的连接:SQLSTATE [HY000] [1045]用户'root'@'localhost'的访问被拒绝(使用密码:是)
我该如何解决? 我通过MySql Workbench用此登录名和密码连接起来很好。 是什么阻止Cake Framework做到这一点?
您是否加载了使您能够在配置中连接到MYSQL的模块? 基本上,您需要确保php.ini的以下行注释为extension = php_mysql.dll extension = php_mysqli.dll
用户名或密码不正确时,通常会显示此错误消息。
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)
因此请确保root用户的密码为root。
在MySQL中,默认root的密码为空。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.