gpt4 book ai didi

mysql - MAMP - phpMyAdmin #2002 - 无法通过套接字 '/Applications/MAMP/tmp/mysql/mysql.sock' 连接到本地 MySQL 服务器

转载 作者:IT老高 更新时间:2023-10-29 00:20:43 28 4
gpt4 key购买 nike

我在 MAMP phpMyAdmin 上工作并且一切正常,直到我从 SQL 选项卡查询 ALTER TABLE 语句。操作太长无法结束所以我决定刷新我的页面。从那时起,我无法再联系到 phpMyAdmin,而且我总是收到这条消息:

#2002 - Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)

我尝试了很多在网上找到的东西,包括 Stackoverflow、Server Fault,...比如重新安装 MAMP,符号链接(symbolic link)到 /tmp/mysql.sock,修改 config.inc.php 等,但没有任何效果。

当我从命令行运行 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)

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

有人遇到过这种问题吗?

最佳答案

我看到的完全一样。 MAMP MySQL 正在运行,此消息来自 PHPMyAdmin

MySQL 说:

#2002 - Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

服务器没有响应(或者本地服务器的套接字配置不正确)。

我确实使用了:sudo ln -s/Applications/MAMP/tmp/mysql/mysql.sock/tmp/mysql.sock允许本地 PHP CLI 访问 MAMP MySQL

我在这里找到了 phpMyAdmin 的配置文件:/Applications/MAMP/bin/phpMyAdmin/config.inc.php

我在配置文件中添加了这个显式路径。

$cfg['Servers'][$i]['socket'] = '/Applications/MAMP/tmp/mysql/mysql.sock';

现在可以了:)

关于mysql - MAMP - phpMyAdmin #2002 - 无法通过套接字 '/Applications/MAMP/tmp/mysql/mysql.sock' 连接到本地 MySQL 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16133467/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com