WP-CLI:建立数据库连接时出错:未定义常量DB_USER

时间:2017-08-19 作者:ecotechie

从wp-cli-github页面获取此信息。我已经在这里搜索了几个小时的文档和网站。目前使用Blue Host托管,他们使用的是1.2.0版:(我似乎无法更新。我有3个wp页面,工作“完美”良好,但另一个无法连接到db。

我可以使用与wp config相同的凭据登录到db。php,清理了db,仍然没有运气。

对此有何想法?试图通过wp cli最终更好地维护这些页面。谢谢

wp核心版本:返回良好。

wp config path --debug
Debug (bootstrap): No readable global config found (0.267s)
Debug (bootstrap): No project config found (0.268s)
Debug (bootstrap): ABSPATH defined: /home/public_html/domain/ (0.269s)
Debug (bootstrap): Begin WordPress load (0.269s)
Debug (bootstrap): wp-config.php path: /home/public_html/domain/wp-config.php (0.269s)
Notice: Use of undefined constant DB_USER - assumed \'DB_USER\' in /home/public_html/domain/wp-includes/load.php on line 404
Notice: Use of undefined constant DB_PASSWORD - assumed \'DB_PASSWORD\' in /home/public_html/domain/wp-includes/load.php on line 404
Notice: Use of undefined constant DB_NAME - assumed \'DB_NAME\' in /home/public_html/domain/wp-includes/load.php on line 404
Notice: Use of undefined constant DB_HOST - assumed \'DB_HOST\' in /home/public_html/domain/wp-includes/load.php on line 404
Notice: Undefined variable: table_prefix in /home/public_html/domain/wp-settings.php on line 109
Error: 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 `DB_HOST`. This could mean your host’s database server is down.
wp配置。php:

<?php
/**
 * The base configurations of the WordPress.
 *
 * This file has the following configurations: MySQL settings, Table Prefix,
 * Secret Keys, WordPress Language, and ABSPATH. You can find more information
 * by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
 * wp-config.php} Codex page. You can get the MySQL settings from your web host.
 *
 * This file is used by the wp-config.php creation script during the
 * installation. You don\'t have to use the web site, you can just copy this file
 * to "wp-config.php" and fill in the values.
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define(\'DB_NAME\', \'dbname\');

/** MySQL database username */
define(\'DB_USER\', \'dbuser\');

/** MySQL database password */
define(\'DB_PASSWORD\', \'pass\');

/** MySQL hostname */
define(\'DB_HOST\', \'localhost\');

/** Database Charset to use in creating database tables. */
define(\'DB_CHARSET\', \'utf8\');

/** The Database Collate type. Don\'t change this if in doubt. */
define(\'DB_COLLATE\', \'\');

/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define(\'AUTH_KEY\',         \'\');
define(\'SECURE_AUTH_KEY\',  \'\');
define(\'LOGGED_IN_KEY\',    \'\');
define(\'NONCE_KEY\',        \'\');
define(\'AUTH_SALT\',        \'\');
define(\'SECURE_AUTH_SALT\', \'\');
define(\'LOGGED_IN_SALT\',   \'\');
define(\'NONCE_SALT\',       \'\');

/**#@-*/

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each a unique
 * prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = \'wps_\';

/**
 * WordPress Localized Language, defaults to English.
 *
 * Change this to localize WordPress. A corresponding MO file for the chosen
 * language must be installed to wp-content/languages. For example, install
 * de_DE.mo to wp-content/languages and set WPLANG to \'de_DE\' to enable German
 * language support.
 */
define(\'WPLANG\', \'\');

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 */
define(\'WP_DEBUG\', false);

define( \'AUTOSAVE_INTERVAL\', 300 );
define( \'WP_POST_REVISIONS\', 5 );
define( \'EMPTY_TRASH_DAYS\', 7 );
define( \'WP_CRON_LOCK_TIMEOUT\', 120 );
/* That\'s all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
if ( !defined(\'ABSPATH\') )
    define(\'ABSPATH\', dirname(__FILE__) . \'/\');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . \'wp-settings.php\');

1 个回复
SO网友:ecotechie

看起来问题出在wp配置上。php

虽然不确定是什么。我复制了wp config示例的内容。php,同时保持相同的db凭据,并开始工作。然后我恢复了更改,它仍在工作。。。

唯一的区别是:

最初,在替换文件时,盐没有设置。

还有这些线条。。。

define( \'AUTOSAVE_INTERVAL\', 300 );
define( \'WP_POST_REVISIONS\', 5 );
define( \'EMPTY_TRASH_DAYS\', 7 );
define( \'WP_CRON_LOCK_TIMEOUT\', 120 );
如果它回来了,我会看看4个定义。。。希望这对别人有帮助,我简直是疯了!!

结束

相关推荐

Database Query not working

我一直在关注SteveMarks的一个教程,该教程介绍了如何将帖子中的信息添加到新的Database Table 和往常一样postmeta 一然而,无论我尝试什么,它都不会将信息存储在新表中,有人能看到我的错误吗?教程可在以下位置获得:http://biostall.com/performing-a-radial-search-with-wp_query-in-wordpress 我的帖子类型是festival-event 我将自定义帖子类型的名称与函数中的名称相同,以查看是否遗漏了某些内容。这个SQL