还有其他几篇关于此的帖子,但似乎没有一个答案对我有用.
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"丢失或无法创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!