CakePHP数据库连接“Mysql”缺少,或无法创建 [英] CakePHP Database connection "Mysql" is missing, or could not be created

查看:532
本文介绍了CakePHP数据库连接“Mysql”缺少,或无法创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我浏览到本地机器上的CakePHP页面时,有一个错误:


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


当我运行这个有用的代码在我的home.ctp,我得到以下响应:



< blockquote>

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


Users / Ben / Sites / myapp / app / Config / database.php 看起来像这样(我设置MAMP查找用户/ Ben / / p>

 <?php 
class DATABASE_CONFIG {

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



我创建了一个名为 code>与密码 mypass 并创建一个数据库 CV 下。此外,我不能在任何地方提到一个测试数据库。帮助?

解决方案

到底是什么对我来说是我在数据库中创建了一个表,数据。



为了让CakePHP识别MySql连接,必须有一个包含数据的表。


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

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

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

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

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

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',
    );
}

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?

解决方案

What did it for me in the end was that I had created a table in my database, but there was no data in it.

In order for CakePHP to recognize the MySql connection, there has to be a table with data in it.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆