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

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

问题描述

我试图从 cake 命令行工具生成模型代码.但是遇到了这个问题.

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.

I'm using 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天全站免登陆