简体   繁体   English

CakePHP'Cake无法连接到数据库'

[英]CakePHP 'Cake is NOT able to connect to the database'

I've looked at this post about a similar issue: 我看过有关类似问题的这篇文章:

CakePHP: Can't access MySQL database CakePHP:无法访问MySQL数据库

and I've tried everything they mentioned in there including: 我已经尝试了他们在其中提到的所有内容,包括:

  1. Changing my database.php so that the 'port' attribute for both $default and $test are the location of my mysqld.sock file 更改我的database.php,以便$ default和$ test的'port'属性都是我的mysqld.sock文件的位置
  2. Changing the 'port' attribute to the actual integer that represents the port in my my.cnf mysql config 将'port'属性更改为代表my.cnf mysql配置中端口的实际整数
  3. Changing the mysql socket locations in php.ini to the location of my mysqld.sock file 将php.ini中的mysql套接字位置更改为我的mysqld.sock文件的位置

I'm using ubuntu 11.04, apache 2.2.17, mysql 5.1.54, and CakePHP 1.3.10. 我正在使用ubuntu 11.04,apache 2.2.17,mysql 5.1.54和CakePHP 1.3.10。 My install of mysql and apache don't seem to match any conventions, as in, all the config files are there, they are all just in really weird places--I'm not sure why that is, but I've tried reinstalling both programs multiple times with the same results... 我安装的mysql和apache似乎没有任何约定,例如,所有配置文件都在那儿,它们都只是在非常奇怪的地方-我不确定为什么会这样,但是我尝试过重新安装两个程序都多次具有相同的结果...

At any rate, I can log into mysql from the terminal and use it normally, and apache is working because I can see the CakePHP default homepage. 无论如何,我可以从终端登录mysql并正常使用它,而apache可以正常工作,因为我可以看到CakePHP的默认主页。 I just can't get it to change the message 'Cake is NOT able to connect to the database'. 我只是无法更改消息“蛋糕无法连接到数据库”。

SOLVED: Figured it out, had to change php.ini so that extension_dir pointed to the correct directory and had to add a line extension=mysql.so. 解决:找到答案,必须更改php.ini,以便extension_dir指向正确的目录,并必须添加一行extension = mysql.so。

I just got my cake php to work. 我刚拿到我的蛋糕php即可工作。 OMG it sucked. 天哪,它很烂。 I'm going to make a video tutorial on my blog when I get a chance to make it easy to install and show all the errors and how to fix them. 当我有机会轻松安装并显示所有错误以及如何修复它们时,我将在我的博客上制作一个视频教程。

go into apache and turn this on in the apache modules: rewrite_module. 进入apache并在apache模块中将其打开:rewrite_module。 For me in wamp, I just go to apache -> apache modules -> rewrite_module. 对于我来说,我只是去apache-> apache modules-> rewrite_module。

Then restart. 然后重新启动。 I had to do this 3 times before it worked. 我必须做3次才能生效。

Then go into the php.ini and turn this on: extension=php_pdo_mysql.dll, by getting rid of the semicolon in the front of it. 然后去掉php.ini并打开它:extension = php_pdo_mysql.dll,方法是摆脱前面的分号。 Then restart again. 然后重新启动。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM