我们学校的 Drupal 网站在升级后崩溃了。MySQL 正在运行,但无法连接到数据库。MyphpAdmin 返回错误 2002。![MySQL 活动截图。][1] Drupal 6.22(尝试升级后)在 Apple Xserve 10.4.11 上运行 MySQL 5.1.37。我该如何重新连接到数据库并恢复 Drupal 数据?
driscollx:/usr/local/mysql root# mysqladmin status -u admin2 -p
Enter password:
Uptime: 59788 Threads: 1 Questions: 3 Slow queries: 0 Opens: 15 Flush tables: 1 Open tables: 8 Queries per second avg: 0.0
driscollx:/usr/local/mysql root# mysqladmin version -u admin2 -p
Enter password:
mysqladmin Ver 8.41 Distrib 4.1.22, for apple-darwin8.0 on powerpc
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Server version 5.1.37-log
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/mysql/mysql.sock
Uptime: 16 hours 36 min 47 sec
Threads: 1 Questions: 4 Slow queries: 0 Opens: 15 Flush tables: 1 Open tables: 8 Queries per second avg: 0.0
driscollx:/usr/local/mysql root# 9-10settings.php
su: 9-10settings.php: command not found
driscollx:/usr/local/mysql root# mysqladmin version -h 127.0.0.1 -u admin2 -p
Enter password:
mysqladmin Ver 8.41 Distrib 4.1.22, for apple-darwin8.0 on powerpc
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Server version 5.1.37-log
Protocol version 10
Connection 127.0.0.1 via TCP/IP
TCP port 3306
Uptime: 16 hours 41 min 20 sec
Threads: 1 Questions: 5 Slow queries: 0 Opens: 15 Flush tables: 1 Open tables: 8 Queries per second avg: 0.0
driscollx:/usr/local/mysql root#
答案1
您update.php
已经运行了吗?如果没有,则您的数据库不受影响;只需回滚 DocumentRoot 的内容,您就可以恢复业务。如果运行了,那么您可能要面对更复杂的问题。
假设您运行了 update.php,或者如果您只是希望实际更新您的站点而不是执行回滚,那么您最好的选择可能是找出站点无法连接到数据库服务器的原因。根据您描述的设置,我猜想 PHP 找不到您的 MySQL 套接字文件。有一些很好的方法可以解决这个问题,但为了方便起见,我建议简单地将in@localhost
的部分更改为 read 。这将强制通过 TCP 而不是套接字进行连接。然后您可以从容地追踪套接字从哪里消失了。$db_url
settings.php
@127.0.0.1