問題描述
還有其他幾篇關于此的帖子,但似乎沒有一個答案對我有用.
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模板網!