数据库连接“Mysql”缺少和mysql.sock丢失 [英] Database connection "Mysql" is missing and mysql.sock is missing

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

问题描述

我试图从蛋糕命令行工具生成模型代码。但有这个问题。

I was trying to generate model code from cake command line tool. But got this issue.

Warning Error: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in [/Users/test/Google_WWW/project_name/lib/Cake/Model/Datasource/Database/Mysql.php, line 177]

Error: Database connection "Mysql" is missing, or could not be created. (although it's showing that mysql database is connected at localhost in cakephp directory)

我使用MAMP。

我搜索了很多,并找到了一些解决方案。例如,此
CakePHP:没有这样的文件或目录(试图通过unix:///var/mysql/mysql.sock连接)

I searched a lot and found some solutions. For instance,this CakePHP: No such file or directory (trying to connect via unix:///var/mysql/mysql.sock)

或者我也可以做一个符号链接mysql.sock。

or I can also make a symbolic link of mysql.sock.

/Applications/MAMP/tmp/mysql/mysql.sock (not present in directory)

但在我做任何事情之前,问题是mysql.sock文件不存在于此目录。我尝试重新安装MAMP但仍没有mysql.sock。

But before i do anything, the problem is mysql.sock file isn't present in this directory. I have tried re-installing the MAMP but still no mysql.sock.

请帮我解决这个问题吗?我可以创建自己的mysql.sock文件..

Please help me solve this problem ? Can I create my own mysql.sock file..?

编辑:我的数据库配置

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


推荐答案

MAMP对于mysql是奇怪的。有机会,你需要设置一个符号链接,所以它知道在哪里找到它。类似:

MAMP is strange when it comes to mysql. Chances are you need to set up a symbolic link so it knows where to find it. Something like:

sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock

这篇关于数据库连接“Mysql”缺少和mysql.sock丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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