只用一个数据库装多个Wordpress
如果你的空间服务商只提供一个mysql数据库,但是还想装两个甚至更多个wordpress?
如果出于经济考虑,你想和朋友共用一个mysql数据库,而建立不同的wordpress?
如果你在A公司买的php空间,在B公司买的mysql,如果搭建起wordpress?
今天在研究wordpress时,发现上面问题都可以在wp-config.php中圆满解决。
// ** MySQL settings ** //
define('DB_NAME', 'wordpress'); // The name of the database
define('DB_USER', 'username'); // Your MySQL username
define('DB_PASSWORD', 'password'); // ...and password
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
// You can have multiple installations in one database if you give each a unique prefix
$table_prefix = 'wp_'; // Only numbers, letters, and underscores please!
// Change this to localize WordPress. A corresponding MO file for the
// chosen language must be installed to wp-includes/languages.
// For example, install de.mo to wp-includes/languages and set WPLANG to 'de'
// to enable German language support.
define ('WPLANG', '');
/* That's all, stop editing! Happy blogging. */
define('ABSPATH', dirname(__FILE__).'/');
require_once(ABSPATH.'wp-settings.php');
?>
以上是wp-config.php文件的全部内容。关键就在$table_prefix参数的值上,如果你要在一个数据库中搭建多个wp,只需在此处设置不同的值即可,而数据库的名称、用户、密码都不变。
如果php空间和mysql是分开在两地的,那么只需在DB_HOST的参数值中天填写好mysql所在的服务器地址即可。
Hoo,原来很多东西自己只要稍稍研究一下就可以有不凡的发现!
ps: 利用刚刚研究得到的成果,Leon顺便开通了一个子域名en.ileon.org,决定用英文,内容正在决定中。^_^

不错!加油!
^_^
aw,HustEI的大牛
呵呵,妙招啊
受益