简体   繁体   English

CakePHP WAMP-数据库Mysql连接丢失

[英]CakePHP WAMP - Database Mysql connection missing

I have scoured the web for an answer but as of now have been unsuccessful. 我已经在网上搜寻了答案,但到目前为止仍未成功。 I am attempting to connect CakePHP to a database. 我正在尝试将CakePHP连接到数据库。 But I keep getting the same response: 但我一直得到同样的回应:

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

Here is part of my database.php file 这是我的database.php文件的一部分

public $default = array(
    'datasource' => 'Database/Mysql',
    'persistent' => false,
    'host' => 'localhost',   
    'login' => 'root',
    'password' => '',
    'database' => 'cake',
    'prefix' => '',
    //'encoding' => 'utf8',
);

^I've also tried different host/login combinations based from the access privileges list in phpmyadmin. ^我还根据phpmyadmin中的访问权限列表尝试了不同的主机/登录组合。

I think one problem might be that Wampserver is finding the wrong php.ini file. 我认为一个问题可能是Wampserver找到了错误的php.ini文件。 It seems that it is loading the file at: "C:\\Program Files (x86)\\PHP\\php.ini" instead of something under "C:\\wamp...". 似乎它正在以下位置加载文件:“ C:\\ Program Files(x86)\\ PHP \\ php.ini”,而不是“ C:\\ wamp ...”下的内容。 How would I set it to point at the right file?? 我将如何设置它指向正确的文件?

However, I had added the line "extension=php_pdo_mysql.dll" to both files and still no luck. 但是,我在这两个文件中都添加了“ extension = php_pdo_mysql.dll”行,但仍然没有运气。 Any help would be appreciated. 任何帮助,将不胜感激。

I had the exact same issue. 我有完全相同的问题。 There was no problem in the mysql database as it was accessible through phpMyadmin and other applications running on the server. mysql数据库中没有问题,因为可以通过phpMyadmin和服务器上运行的其他应用程序进行访问。 The issue was caused due to the mysql port not mentioned alongwith the host. 该问题是由于未与主机一起提到的mysql端口引起的。 Append the port with the host like... 'host' => 'localhost:3307'. 将端口附加到主机,例如...'host'=>'localhost:3307'。

public $default = array(
    'datasource' => 'Database/Mysql',
    'persistent' => false,
    'host' => 'localhost:3307',
    'login' => 'root',
    'password' => 'mypass',
    'database' => 'cake_todos',
    'prefix' => '',
    //'encoding' => 'utf8',
);

Now, how to know the mysql port? 现在,如何知道mysql的端口? For that you need to go to the server configuration file.. eg the in my case it was the properties.ini file in the home directory of the wamp folder. 为此,您需要转到服务器配置文件。例如,在我的情况下,它是wamp文件夹的主目录中的properties.ini文件。 Open the file and you will most probably find an entry like this: 打开文件,您很可能会找到如下所示的条目:

mysql_port=3307 mysql_host=127.0.0.1 mysql_port = 3307 mysql_host = 127.0.0.1

So, here it is, the mysql_port. 因此,这里是mysql_port。 Hope it helps. 希望能帮助到你。

First check there is database called cake in your localhost/phpmyadmin, and if that mysql use the username root and no password and also make sure you set php_mysql on the right php.ini file ( extension=php_mysql.dll ). 首先检查您的localhost / phpmyadmin中是否有一个名为Cake的数据库,并且如果该mysql使用用户名root且没有密码,还请确保在正确的php.ini文件( extension=php_mysql.dll )上设置了php_mysql。

Second, if you think the problem is because of php.ini file location, you can set it: 其次,如果您认为问题是由于php.ini文件位置引起的,则可以进行设置:

  1. go to your wamp folder (C:\\wamp) and 转到您的wamp文件夹(C:\\ wamp),然后
  2. under that folder you'll find wampmanager.ini file and 在该文件夹下,您会找到wampmanager.ini文件,
  3. Find php.ini word in that file you'll get this kind of line (Type: item; Caption: "php.ini"; Glyph: 6; Action: run; FileName: "notepad.exe"; parameters: "...path here...") and locate the path and set "C:/wamp/bin/apache/apache2.2.21/bin/php.ini" 在该文件中找到php.ini字样,您将获得以下代码行(Type: item; Caption: "php.ini"; Glyph: 6; Action: run; FileName: "notepad.exe"; parameters: "...path here...")然后找到路径并设置"C:/wamp/bin/apache/apache2.2.21/bin/php.ini"

please tell me (vote) if it works. 请告诉我(投票)是否可行。 I hope it helps. 希望对您有所帮助。

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 CakePHP 数据库连接“Mysql”丢失,或无法创建 - CakePHP Database connection "Mysql" is missing, or could not be created CakePHP烘焙错误:数据库连接“ Mysql”丢失,或无法创建 - CakePHP Bake Error: Database connection “Mysql” is missing, or could not be created CakePHP 2.0:数据库连接“Mysql”丢失或无法创建 - CakePHP 2.0 : Database connection “Mysql” is missing, or could not be created CakePHP Bake Shell错误:数据库连接“Mysql”丢失或无法创建 - CakePHP Bake Shell Error: Database connection “Mysql” is missing, or could not be created 带有Cakephp内联的错误消息-缺少数据库连接 - An error message with cakephp inline - Missing Database Connection CakePHP数据库连接“ Mysql”丢失,或无法创建。 core.php和bootstrap.php - CakePHP Database connection “Mysql” is missing, or could not be created. core.php and bootstrap.php 需要帮助,以MAMP调试CakePHP与MySQL的连接,错误:数据库中缺少表(出于某种原因) - Need Help Debugging CakePHP Connection to MySQL with MAMP, error: missing table in database (for what seems like no reason) 使用“ Mysql”的数据库连接丢失或无法连接 - A Database connection using “Mysql” was missing or unable to connect 使用wamp连接本地数据库的php - php connection to the local database with wamp 缺少数据库表 - CakePHP - Missing database table - CakePHP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM