当前位置: 首页 > wordpress>阅读正文

wordpress数据库配置

2022.1.24 朱丰华 1062 次 留下评论 638字

wordpress数据库配置信息,放在根目录下的wp-config.php中,一般来说你可以看到以下几行

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'aaa' );     // 数据库名称

/** MySQL database username */
define( 'DB_USER', 'bbb' );     //  数据库用户名

/** MySQL database password */
define( 'DB_PASSWORD', 'ccc' );
   // 数据库密码

/** MySQL hostname */
define( 'DB_HOST', 'localhost' );  // 数据库主机
/**
 * 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_';    // 数据库前缀

wp使用define定义了这几个全局变量,修改数据库信息直接编辑该文件保存即可。

因为是全局变量,可在主题函数中调用,例如:

function test(){
    global $table_prefix;
    $dbname = DB_NAME;
}

本篇完,还有疑问?留下评论吧

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注