CakePHP 数据库连接“Mysql"丢失或无法创建

CakePHP Database connection quot;Mysqlquot; is missing, or could not be created(CakePHP 数据库连接“Mysql丢失或无法创建)
本文介绍了CakePHP 数据库连接“Mysql"丢失或无法创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

还有其他几篇关于此的帖子,但似乎没有一个答案对我有用.

There have been several other posts about this, but none of the answers seemed to work for me.

当我在本地机器上导航到 CakePHP 页面时,出现一个错误:

When I navigate to the CakePHP page on my local machine, there is one error:

Cake 无法连接到数据库.数据库连接Mysql"缺失或无法创建.

Cake is NOT able to connect to the database. Database connection "Mysql" is missing, or could not be created.

当我在 home.ctp 中运行 这个有用的代码时,我得到以下回复:

When I run this helpful code in my home.ctp, I get the following response:

错误!:SQLSTATE[42000] [1049] 未知数据库 'test'

Error!: SQLSTATE[42000] [1049] Unknown database 'test'

但是,我的 Users/Ben/Sites/myapp/app/Config/database.php 看起来像这样(我设置 MAMP 以在 Users/Ben/Sites 中查找文档根目录):

However, my Users/Ben/Sites/myapp/app/Config/database.php looks like this (I set MAMP to look for the document root in Users/Ben/Sites):

<?php
class DATABASE_CONFIG {

    public $default = array(
        'datasource' => 'Database/Mysql',
        'persistent' => false,
        'host' => 'localhost',
        'login' => 'Ben',
        'password' => 'mypass',
        'database' => 'CV',
    );
}

我创建了一个名为 Ben 的 mysql 用户,密码为 mypass,并在其下创建了一个名为 CV 的数据库.此外,我在任何地方都找不到 test 数据库的提及.有帮助吗?

I have created a mysql user called Ben with password mypass and created a database called CV under that. Moreover, I can't find mention of a test database anywhere. Help?

推荐答案

尝试添加套接字:

'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',

这篇关于CakePHP 数据库连接“Mysql"丢失或无法创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Codeigniter htaccess to remove index.php and www(Codeigniter htaccess 删除 index.php 和 www)
htaccess mod_rewrite part of url to GET variable(htaccess mod_rewrite url 的一部分到 GET 变量)
Replacing a querystring parameter value using mod_rewrite(使用 mod_rewrite 替换查询字符串参数值)
.htaccess in subdirectory #39;overriding#39; parent htaccess(子目录“覆盖父 htaccess 中的 .htaccess)
How to rewrite SEO friendly url#39;s like stackoverflow(如何像stackoverflow一样重写SEO友好的url)
Is it okay to have a very long .htaccess file?(有一个很长的 .htaccess 文件可以吗?)