MAMP - phpMyAdmin #2002 - 无法通过套接字“/Applications/MAMP/tmp/mysql/mysql.sock"连接到本地 MySQL 服务器
我在 MAMP phpMyAdmin 上工作,一切正常,直到我从 SQL 选项卡查询 ALTER TABLE
语句.操作太长而无法结束,所以我决定刷新我的页面.从这个时候起,我再也无法访问 phpMyAdmin,而且我总是收到这条消息:
I was working on MAMP phpMyAdmin and everything worked well until i query an ALTER TABLE
statement 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 :
#2002 - Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)
我已经尝试了很多在网上找到的东西,包括 Stackoverflow、Server Fault,......比如重新安装 MAMP,符号链接到 /tmp/mysql.sock
,修改 config.inc.php
等,但没有任何效果.
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.
当我从命令行运行 mysql
时,一切都很好:
Everything's good when i run mysql
from command line :
$ /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)
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
并且套接字文件存在:
$ 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 ?
推荐答案
我看到的完全一样.MAMP MySQL 正在运行,此消息来自 PHPMyAdmin
I am seeing exactly the same. MAMP MySQL running, and this messgage from PHPMyAdmin
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).
我确实使用了:sudo ln -s/Applications/MAMP/tmp/mysql/mysql.sock/tmp/mysql.sock
允许本地 PHP CLI 访问 MAMP MySQL
I did use : sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
to allow local PHP CLI access to MAMP MySQL
我在这里找到了 phpMyAdmin 的配置文件:/Applications/MAMP/bin/phpMyAdmin/config.inc.php
I found the config file for phpMyAdmin here: /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';
现在可以了:)
相关文章