-2

我已经在本地创建了一个可能的 wordpress 站点的副本(导入 SQL),并且连续几天经历一个连接错误,我真的几乎要放弃了。

我经历了几个数据库连接错误,现在我在另一个我无法在论坛中找到答案的问题上。

下载并导入数据库后,我在本地运行网站,所以我有:

       define('DB_NAME', 'db_mysitename');

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

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

    /** MySQL hostname */
    define('DB_HOST', 'local.mysitename');

    /** 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', '');

    /** debuging mode*/
    define( 'WP_DEBUG', true );
    define( 'SCRIPT_DEBUG', true );

但是当我导航到 local.mysistename/ 时,我得到以下信息:

Warning: mysql_connect(): Unknown MySQL server host 'http' (2) in /Users/me/Sites/mysitename/wp-includes/wp-db.php on line 1141

所以我在 db-test.php 中添加了一个数据库测试脚本

这不合逻辑地起作用:

   wp_commentmeta wp_comments wp_links wp_options wp_postmeta wp_posts wp_term_relationships wp_term_taxonomy wp_terms wp_usermeta wp_users

为什么它适用于测试脚本而不适用于网站?有任何想法吗?

请帮忙。

4

2 回答 2

0

local.mysitename looks like an alias you would have listed in your hosts file, which means an alias for a location that you access over http. You don't generally access databases over http connections, so that looks like it could be the problem. If the database is running on your computer, then you'll want to use localhost or whatever your machine's local IP is.

于 2013-11-06T18:12:33.923 回答
0

只需将以上所有信息放在您的 wordpress 博客根目录下的 wp-config.php 文件中,然后将 define('DB_HOST', 'local.mysitename') 更改为 define('DB_HOST', 'localhost')

它会起作用的

于 2013-11-06T18:11:46.443 回答