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"丢失或无法创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)