Wordpress:建立数据库连接时出错。是的,我已经尝试过了。还有那个

发布于 2024-09-18 07:37:59 字数 1917 浏览 3 评论 0原文

这让我抓狂!我的 MacBook Pro 上安装了一个 Wordpress 测试实例,但它突然停止工作。如果我前往 http://localhost:9003/wp-admin/ 我得到:

建立数据库连接时出错

这要么意味着 用户名和密码信息在 您的 wp-config.php 文件不正确 或者我们无法联系数据库 服务器位于本地主机。这可能意味着 您主机的数据库服务器已关闭。

你确定你有正确的 用户名和密码?

你确定吗 您输入了正确的内容 主机名?

您确定 数据库服务器正在运行?

如果你是 不确定这些术语对您意味着什么 也许应该联系你的主人。如果 你仍然需要帮助,你可以随时 访问 WordPress 支持论坛。

哼!我已经很久没有碰过配置了。以下是相关行现在的样子:

define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', 'wordpress');
define('DB_HOST', 'localhost');
$table_prefix  = 'wp_';

这些值都很好:

$ mysql -h localhost -u wordpress --password=wordpress \
> wordpress -e 'select user_login from wp_users'
+------------+
| user_login |
+------------+
| simon      |
+------------+

MySQL 错误日志中没有任何内容,Apache 的错误日志中也没有任何内容。我尝试过使用不同的 MySQL 用户和不同的数据库,但出现相同的错误。我很沮丧 - 有 WordPress 专家知道我错过了什么吗?


php --ri mysql 的输出:

$ php --ri mysql

mysql

MySQL Support => enabled
Active Persistent Links => 0
Active Links => 0
Client API version => mysqlnd 5.0.7-dev - 091210 - $Revision: 294543 $

Directive => Local Value => Master Value
mysql.allow_persistent => On => On
mysql.max_persistent => Unlimited => Unlimited
mysql.max_links => Unlimited => Unlimited
mysql.default_host => no value => no value
mysql.default_user => no value => no value
mysql.default_password => no value => no value
mysql.default_port => no value => no value
mysql.default_socket => /var/mysql/mysql.sock => /var/mysql/mysql.sock
mysql.connect_timeout => 60 => 60
mysql.trace_mode => Off => Off
mysql.allow_local_infile => On => On

This is driving me nuts! I have a test instance of Wordpress installed on my MacBook Pro, which has suddenly stopped working. If I head for http://localhost:9003/wp-admin/ I get:

Error establishing a database connection

This either means that the
username and password information in
your wp-config.php file is incorrect
or we can't contact the database
server at localhost. This could mean
your host's database server is down.

Are you sure you have the correct
username and password?

Are you sure
that you have typed the correct
hostname?

Are you sure that the
database server is running?

If you're
unsure what these terms mean you
should probably contact your host. If
you still need help you can always
visit the WordPress Support Forums.

Hmmph! I haven't touched the config for ages. Here's how the relevant lines look right now:

define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', 'wordpress');
define('DB_HOST', 'localhost');
$table_prefix  = 'wp_';

The values are all good:

$ mysql -h localhost -u wordpress --password=wordpress \
> wordpress -e 'select user_login from wp_users'
+------------+
| user_login |
+------------+
| simon      |
+------------+

There's nothing in the MySQL error log, nor in Apache's error log. I've tried using a different MySQL user and a different database, but I get the same error. I'm scuppered - any WordPress gurus out there know what I'm missing?


Output of php --ri mysql:

$ php --ri mysql

mysql

MySQL Support => enabled
Active Persistent Links => 0
Active Links => 0
Client API version => mysqlnd 5.0.7-dev - 091210 - $Revision: 294543 $

Directive => Local Value => Master Value
mysql.allow_persistent => On => On
mysql.max_persistent => Unlimited => Unlimited
mysql.max_links => Unlimited => Unlimited
mysql.default_host => no value => no value
mysql.default_user => no value => no value
mysql.default_password => no value => no value
mysql.default_port => no value => no value
mysql.default_socket => /var/mysql/mysql.sock => /var/mysql/mysql.sock
mysql.connect_timeout => 60 => 60
mysql.trace_mode => Off => Off
mysql.allow_local_infile => On => On

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

当梦初醒 2024-09-25 07:37:59

确定网络共享已打开?

MySQL 通过首选项窗格运行:
http://dev.mysql-installation-macosx-prefpane.html mysql.com/doc/mysql-macosx-excerpt/5.1/en/mysql-installation-macosx-prefpane.html

可以尝试 phpmyadmin 检查数据库: http://www.phpmyadmin.net

Sure web sharing is turned on?

And MySQL is running via the Preferance Pane:
http://dev.mysql.com/doc/mysql-macosx-excerpt/5.1/en/mysql-installation-macosx-prefpane.html

Might try phpmyadmin to check the database: http://www.phpmyadmin.net

林空鹿饮溪 2024-09-25 07:37:59

如果您确实没有更改任何配置设置,那么可能由于普通原因无法建立数据库连接。也许是一个愚蠢的问题,但是您是否尝试过重新启动计算机或至少重新启动 MySQL?也许 MySQL 只是资源不足,无法满足您网站的请求。

If you truly didn't change any of your configuration settings, then maybe the database connection can't be established for mundane reasons. Perhaps a silly question, but did you try restarting your computer or at least MySQL? Maybe MySQL is just running low on resources and cannot service your web site's request.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文