Error establishing a database connection

2025-10-10 21:26:15

1、点开xampp里面的Volumes,找到下面的Explore,点击进入。

Error establishing a database connection

2、找到htdocs文件夹,点击进入。

Error establishing a database connection

3、找到wordpress文件夹,点击进入。

Error establishing a database connection

4、这时候你可以看到很多带".php"后缀的文件,随意复制一个。我复制的是wp-config-sample.php,之后用windows的记事本或者mac的文本编辑器打开,将里面的内容全部删掉。

Error establishing a database connection

5、将下面的这段代码全部复制进上一步打开的那个“.php“文件里。

<?php

/**

 * The base configuration for WordPress

 *

 * The wp-config.php creation script uses this file during the

 * installation. You don't have to use the web site, you can

 * copy this file to "wp-config.php" and fill in the values.

 *

 * This file contains the following configurations:

 *

 * * MySQL settings

 * * Secret keys

 * * Database table prefix

 * * ABSPATH

 *

 * @link https://codex.wordpress.org/Editing_wp-config.php

 *

 * @package WordPress

 */

// ** MySQL settings - You can get this info from your web host ** //

/** The name of the database for WordPress */

define( 'DB_NAME', 'mysql' );

/** MySQL database username */

define( 'DB_USER', 'root' );

/** MySQL database password */

define( 'DB_PASSWORD', '' );

/** MySQL hostname */

define( 'DB_HOST', 'localhost' );

/** Database Charset to use in creating database tables. */

define( 'DB_CHARSET', 'utf8mb4' );

/** 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',         'Qr6L0@Pg VbeFg`YABB_:olGY+]gE:x/$9i`EOgG,|WviTEh70d-n%V%ah*@jg`6' );

define( 'SECURE_AUTH_KEY',  '04dmkzGF*RQM>{=rX;DX}rh>N^*5}/=oWcRB&Grvd*$h{%X+~3TbE[Ny9Y/!t>J~' );

define( 'LOGGED_IN_KEY',    '6@^e(a!gc0sJg4j.th~JQ:qhrIZF[fL O@ovERp(9)NK-MNAXxr9e>w &B?e.N($' );

define( 'NONCE_KEY',        'reTi<W1uhz2GOj%R<+@J9]h-E0@[drW3EY`7/.(lFTLo2l]Eja,sN| wsUS-xTE*' );

define( 'AUTH_SALT',        's]bO^eO5 X(]Dj/XT{XkfUS;b-_P7-5erUYu&)ELF2fK2wn-{wuY%wx[Qn%lDtPu' );

define( 'SECURE_AUTH_SALT', 'OnLYvcFvR{><T7|@ECVU`e(.FG9kPkK`tXPnhbx#@5ywyl6he;:=:<}4i9g7^#/)' );

define( 'LOGGED_IN_SALT',   'oQ4Lh~+de_pb<^,=!pvt:2jmm!C|Zeq|j0U$wl22[cIVY956>*p(`.s>7.dHk9s|' );

define( 'NONCE_SALT',       ' oHHlSp7Orxxq^o? ^#?o/1ljZi^aoI@|J%?= h0S%[;aW6>cjJ%H}}/:NSmCO>>' );

/**#@-*/

/**

 * 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.

 *

 * For information on other constants that can be used for debugging,

 * visit the Codex.

 *

 * @link https://codex.wordpress.org/Debugging_in_WordPress

 */

define( 'WP_DEBUG', false );

/* That's all, stop editing! Happy publishing. */

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

6、找到这个文件顶部的“已编辑”,点开重命名为“wp-config.php“,回车保存。

Error establishing a database connection

7、做完这些之后,亲测Error establishing a database connection已消失。

Error establishing a database connection

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢