首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用MySQL时无法连接到本地CakePHP数据库

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

Stack Overflow用户
提问于 2015-05-06 15:51:01
回答 2查看 3.6K关注 0票数 1

我有一个配置:

代码语言:javascript
复制
'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框架做同样的事情呢?

EN

回答 2

Stack Overflow用户

发布于 2015-05-06 15:59:03

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

票数 0
EN

Stack Overflow用户

发布于 2015-05-11 10:53:47

当用户名或密码不正确时,通常会显示此错误消息。

代码语言:javascript
复制
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密码为空。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30081689

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档