php - Wordpress:建立数据库连接时出错。是的,我已经尝试过了。然后

标签 php mysql macos wordpress osx-snow-leopard

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

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.

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

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

最佳答案

关于php - Wordpress:建立数据库连接时出错。是的,我已经尝试过了。然后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3662860/

相关文章:

macos - 是否有任何 OS X 等效于 `hcitool` ?

cocoa - 有关未在文件内容中进行替换的 Xcode 项目模板的特定帮助

php - foreach 结果分为两列

mysql - 加入查询缺失记录

mysql - SQL - 当记录不存在时不从另一个表中检索记录

php - PHP 中的 MYSQL UPDATE 和 SET 语句(500 错误响应)

php - 404 页面未找到 - CodeIgniter 相关

php - 批量更新 Woocommerce 变体价格

php - 如果我搜索 csv 文件,输出会出现几次

macos - 如何设置NSTextView的默认书写方向?