MAMP - phpMyAdmin #2002 - 无法通过套接字'/Applications/MAMP/tmp/mysql/mysql.sock' 连接到本地 MySQL 服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16133467/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MAMP - phpMyAdmin #2002 - Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock'
提问by Yaman
I was working on MAMP phpMyAdmin and everything worked well until i query an ALTER TABLEstatement from SQL tab. Operation was too long to end so i decided to refresh my page. From this time, i cannot reach phpMyAdmin anymore and i always have this message :
我在 MAMP phpMyAdmin 上工作,一切正常,直到我ALTER TABLE从 SQL 选项卡查询语句。操作太长而无法结束,所以我决定刷新我的页面。从这个时候起,我再也无法访问 phpMyAdmin,并且总是收到以下消息:
#2002 - Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)
I've tried a lot of things found on the net, including on Stackoverflow, Server Fault, ... like reinstalling MAMP, symlink to /tmp/mysql.sock, modify config.inc.php, etc, but nothing worked.
我已经尝试了很多在网上找到的东西,包括 Stackoverflow、Server Fault,……比如重新安装 MAMP、符号链接到/tmp/mysql.sock、修改config.inc.php等,但没有任何效果。
Everything's good when i run mysqlfrom command line :
当我从命令行运行时,一切都很好mysql:
$ /Applications/MAMP/Library/bin/mysql -u root -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.29 Source distribution
mysql> SHOW SCHEMAS;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0,65 sec)
mysqldis properly running :
mysqld正在正常运行:
$ ps -e | grep mysql
7007 ?? 0:00.03 /bin/sh /Applications/MAMP/Library/bin/mysqld_safe --port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --lower_case_table_names=0 --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error=/Applications/MAMP/logs/mysql_error_log
7141 ?? 0:00.37 /Applications/MAMP/Library/bin/mysqld --basedir=/Applications/MAMP/Library --datadir=/Applications/MAMP/db/mysql --plugin-dir=/Applications/MAMP/Library/lib/plugin --lower-case-table-names=0 --log-error=/Applications/MAMP/logs/mysql_error_log.err --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --socket=/Applications/MAMP/tmp/mysql/mysql.sock --port=8889
And socket file exist :
并且套接字文件存在:
$ ls -la /Applications/MAMP/tmp/mysql/mysql.sock
srwxrwxrwx 1 user admin 0 21 avr 16:57 /Applications/MAMP/tmp/mysql/mysql.sock
Someone had already faced this kind of issue ?
已经有人遇到过这种问题?
回答by thinkadoo
I am seeing exactly the same. MAMP MySQL running, and this messgage from PHPMyAdmin
我看到的完全一样。MAMP MySQL 正在运行,此消息来自 PHPMyAdmin
MySQL said:
MySQL 说:
#2002 - Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
The server is not responding (or the local server's socket is not correctly configured).
服务器没有响应(或本地服务器的套接字未正确配置)。
I did use : sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sockto allow local PHP CLI access to MAMP MySQL
我确实使用过:sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock允许本地 PHP CLI 访问 MAMP MySQL
I found the config file for phpMyAdmin here: /Applications/MAMP/bin/phpMyAdmin/config.inc.php
我在这里找到了 phpMyAdmin 的配置文件:/Applications/MAMP/bin/phpMyAdmin/config.inc.php
I added this explicit path in the config file.
我在配置文件中添加了这个显式路径。
$cfg['Servers'][$i]['socket'] = '/Applications/MAMP/tmp/mysql/mysql.sock';
Now it works :)
现在它起作用了:)
回答by beth
I got the same response when I went to the default URI via the link from the main Mamp page, which was http://localhost/phpMyAdmin/?lang=en-iso-8859-1&language=English. I tried the previous answer's suggestions to no avail. But then, when I chopped off some of the options in the URI and instead just went to any of the following:
当我通过来自 Mamp 主页面的链接转到默认 URI 时,我得到了相同的响应,即http://localhost/phpMyAdmin/?lang=en-iso-8859-1&language=English. 我尝试了上一个答案的建议无济于事。但是,当我砍掉 URI 中的一些选项而只是转到以下任何一个时:
http://localhost/phpMyAdmin/?language=Englishhttp://localhost/phpMyAdmin/?lang=en-iso-8859-1http://localhost/phpMyAdmin
http://localhost/phpMyAdmin/?language=Englishhttp://localhost/phpMyAdmin/?lang=en-iso-8859-1http://localhost/phpMyAdmin
then it worked.
然后它起作用了。
回答by Rajesh
It may find weird but, I tried deleting the file mysql.sock from the tmp directory and this error disappeared...
它可能会觉得很奇怪,但是,我尝试从 tmp 目录中删除文件 mysql.sock 并且此错误消失了...

