在安装时建立数据库连接时出错

时间:2015-08-04 作者:Francisco Maria Calisto

我在MacOS系统上工作,所有配置都很好,工作正常。现在,我尝试使用与MacOS MAMP中相同的软件将所有工作迁移到Windows,以便在本地主机上运行Wordpress。因此,我在Windows系统上设置了MAMP,并将所有文件从GitHub复制到Windows上的工作站。

问题是,当我尝试在本地主机上访问Wordpress项目时,出现了以下错误:

“建立数据库连接时出错”

enter image description here

我甚至不能wp-config.php 文件,我拿不到。

正在搜索similar 这里的问题我有这个link, 但不是相同的解决方案。

2 个回复
最合适的回答,由SO网友:Satish Mehta 整理而成

创建新文件名wp config。php和粘贴所有代码,然后输入您的db凭据,这将解决您的wp配置问题。

<?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\', \'database_name_here\');

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

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

/** 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\',         \'put your unique phrase here\');
define(\'SECURE_AUTH_KEY\',  \'put your unique phrase here\');
define(\'LOGGED_IN_KEY\',    \'put your unique phrase here\');
define(\'NONCE_KEY\',        \'put your unique phrase here\');
define(\'AUTH_SALT\',        \'put your unique phrase here\');
define(\'SECURE_AUTH_SALT\', \'put your unique phrase here\');
define(\'LOGGED_IN_SALT\',   \'put your unique phrase here\');
define(\'NONCE_SALT\',       \'put your unique phrase here\');

/**#@-*/

/**
 * 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  = \'wp_\';

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

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

SO网友:AddWeb Solution Pvt Ltd

您需要创建wp-config.php 文件此新文件是的副本wp-config-sample.php 在根目录中找到它。

创建此副本后,将其命名为wp-config.php 并在其中设置数据库设置。同时授予访问权限。

如果您不习惯上述措辞,请告诉我。

结束

相关推荐

无法安装插件/WP-CONFIG中的FTP凭据

我的一个Wordpress安装有问题。当我尝试安装插件时,WP会询问我的FTP凭据。我输入了它们,但FTP和FTP都不起作用,但凭据是百分之百正确的。我打开了wp配置。php并将配置粘贴到文件中。当我现在想安装一个插件时,我仍然可以看到必须输入FTP数据的屏幕,屏幕上显示的是WP配置文件中的信息,但显示的错误文本是无法建立到FTP的连接。有人知道这是服务器设置还是这里出了什么问题吗?谢谢