数据库连接“Mysql”丢失,缺少mysql.sock
I was trying to generate model code from cake command line tool. But got this issue.
我试图从cake命令行工具生成模型代码。但得到了这个问题。
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)
I'm using MAMP.
我正在使用MAMP。
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)
我搜索了很多并找到了一些解决方案。例如,这个CakePHP:没有这样的文件或目录(尝试通过unix连接:///var/mysql/mysql.sock)
or I can also make a symbolic link of mysql.sock.
或者我也可以创建一个mysql.sock的符号链接。
/Applications/MAMP/tmp/mysql/mysql.sock (not present in directory)
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文件不存在于此目录中。我试过重新安装MAMP但仍然没有mysql.sock。
Please help me solve this problem ? Can I create my own mysql.sock file..?
请帮帮我解决这个问题?我可以创建自己的mysql.sock文件..?
Edit: My db config
编辑:我的数据库配置
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'root',
'password' => 'root',
'database' => 'db_name',
'prefix' => ''
);
6 个解决方案
#1
8
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:
对于mysql来说,MAMP很奇怪。您可能需要设置符号链接,以便知道在哪里找到它。就像是:
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
更多相关文章
- MySQL的ibdata1文件占用过大瘦身
- 在平台上获取,可移植,更大和更快(无符号)的整数类型
- 如何使用Angular.js从json文件中使用id获取特定数据
- 如何从一个节点生成exe文件。js应用?
- 在批处理文件中使用JSMin
- 使用HTML文件中的React调用.js文件中的Javascript函数
- 在JavaScript中进行文件处理,第四部分:对象URLs
- [转]在网页中加入声音文件,并且用JavaScript对其进行播放控制
- 基于缓冲区数据创建文件