dongmo20030416 2015-05-06 15:51
浏览 228

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

I have this config:

'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'],
],

And i have a local MySql Database with same login params that i've entered above, but on the front page of freshly installed CakePHP in tells me next:

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)

How can i fix it? I'm connecting just fine with this login and password via MySql Workbench. What's stopping Cake framework from doing the same?

  • 写回答

3条回答 默认 最新

  • douxianwu2221 2015-05-06 15:59
    关注

    did you load the module that enable you to connect to the MYSQL in your your configuration. basically you need to make sure that your php.ini has the following line commented extension=php_mysql.dll extension=php_mysqli.dll

    评论

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)