【发布时间】:2017-10-23 08:20:32
【问题描述】:
我有一个大型数据库,我想将其拆分为多个数据库,但连接到我的 WordPress 网站。我通过互联网搜索并找到了使用 WordPress Codex 提供的HyperDB class 的解决方案。我下载了文件,然后尝试如下
$wpdb->add_database(array(
'host' => 'localhost', // If port is other than 3306, use host:port.
'user' => 'root',
'password' => '',
'name' => 'partitioning',
));
/**
* This adds the same server again, only this time it is configured as a slave.
* The last three parameters are set to the defaults but are shown for clarity.
*/
$wpdb->add_database(array(
'host' => 'localhost', // If port is other than 3306, use host:port.
'user' => 'root',
'password' => '',
'name' => 'slave',
'write' => 0,
'read' => 1,
'dataset' => 'global',
'timeout' => 0.2,
));
我正在使用 xampp 作为开发版本。 WordPress 站点安装后,我将 db-config.php 与 wp-config.php 文件目录和 db.php 放在 wp-content 文件夹中。这样做我得到空白页。
谁能详细说明如何设置数据库和HyperDB脚本的过程?我的意思是如何制作从库或HyperDB会自动制作从库?如何将任何表拆分为从数据库?我的意思是整个过程。
【问题讨论】:
-
不要使用这个类,它已经过时了,在任何最近的 PHP 版本中都不起作用
-
那么还有什么可以替代这个呢?
-
我不知道。只需使用您的 wordpress 人员正在使用的任何内容 - wpdb 或它的名称
-
您遇到了什么问题?也许通过优化数据库更容易解决。
-
实际上,我正在构建一个 WordPress 网站,其中包含大约 1000 万种产品。我计划将相应数据库中的产品作为类别名称上传。例如,男性类别的产品将进入男性数据库,就像女性产品将进入女性数据库一样。我的实际数据库大小是 1GB。在这种情况下我能做什么?