Title: HyperDB
Author: Automattic
Published: <strong>Èbìbí  7, 2016</strong>
Last modified: Ọ̀wàrà 12, 2022

---

Ṣàwárí àwọn plugin

![](https://ps.w.org/hyperdb/assets/banner-772x250.jpg?rev=478989)

Plugin yìí **kò tíì ṣe àyẹ̀wò pẹ̀lú àwọn ìtújáde mẹ́ta pàtàkì tó kẹ́yìn ti WordPress**.
Ó lè jẹ́ pé a kò tọ́jú tàbí ṣe àtìlẹ́yìn fún un mọ́, ó sì lè ní àwọn ọ̀ràn ìbámu
nígbà tí a bá lò ó pẹ̀lú àwọn ẹ̀yà WordPress tuntun.

![](https://s.w.org/plugins/geopattern-icon/hyperdb_33353d.svg)

# HyperDB

 Láti ọwọ́ [Automattic](https://profiles.wordpress.org/automattic/)

[Ṣe ìgbàsílẹ̀](https://downloads.wordpress.org/plugin/hyperdb.1.9.zip)

 * [Àwọn àlàyé](https://yor.wordpress.org/plugins/hyperdb/#description)
 * [Àwọn àgbéyẹ̀wò](https://yor.wordpress.org/plugins/hyperdb/#reviews)
 *  [Ìgbéwọlẹ̀](https://yor.wordpress.org/plugins/hyperdb/#installation)
 * [Ìdàgbàsókè](https://yor.wordpress.org/plugins/hyperdb/#developers)

 [Ìrànlọ́wọ́](https://wordpress.org/support/plugin/hyperdb/)

## Àpèjúwe

HyperDB is a very advanced database class that replaces a few of the WordPress built-
in database functions. The main differences are:
 * HyperDB can be connect to an
arbitrary number of database servers, * HyperDB inspects each query to determine
the appropriate database.

It supports:

 * Read and write servers (replication)
 * Configurable priority for reading and writing
 * Local and remote datacenters
 * Private and public networks
 * Different tables on different databases/hosts
 * Smart post-write master reads
 * Failover for downed host
 * Advanced statistics for profiling
 * WordPress Multisite

It is based on the code currently used in production on WordPress.com with many 
MySQL servers spanning multiple datacenters.

## Ìgbéwọlẹ̀

Nothing goes in the plugins directory.

 1. Enter a configuration in `db-config.php`.
 2. Deploy `db-config.php` in the directory that holds `wp-config.php`. This may be
    the WordPress root or one level above. It may also be anywhere else the web server
    can see it; in this case, define `DB_CONFIG_FILE` in `wp-config.php`.
 3. Deploy `db.php` to the `/wp-content/` directory. Simply placing this file activates
    it. To deactivate it, move it from that location or move the config file.

Any value of `WP_USE_MULTIPLE_DB` will be ignored by HyperDB.

## FAQ

### What can I do with HyperDB that I canÌtumọ̀ Yorùbá: ’t do with WPDB?

WordPress.com, the most complex HyperDB installation, manages millions of tables
spanning thousands of databases. Dynamic configuration logic allows HyperDB to compute
the location of tables by querying a central database. Custom scripts constantly
balance database server resources by migrating tables and updating their locations
in the central database.

Stretch your imagination. You could create a dynamic configuration using persistent
caching to gather intelligence about the state of the network. The only constant
is the name of the configuration file. The rest, as they say, is PHP.

### How does HyperDB support replication?

HyperDB does not provide replication services. That is done by configuring MySQL
servers for replication. HyperDB can then be configured to use these servers appropriately,
e.g. by connecting to master servers to perform write queries.

### How does HyperDB support load balancing?

HyperDB randomly selects database connections from priority groups that you configure.
The most advantageous connections are tried first. Thus you can optimize your configuration
for network topology, hardware capability, or any other scheme you invent.

### How does HyperDB support failover?

Failover describes how HyperDB deals with connection failures. When HyperDB fails
to connect to one database, it tries to connect to another database that holds the
same data. If replication hasnÌtumọ̀ Yorùbá: ’t been set up, HyperDB tries reconnecting
a few times before giving up.

### How does HyperDB support partitioning?

HyperDB allows tables to be placed in arbitrary databases. It can use callbacks 
you write to compute the appropriate database for a given query. Thus you can partition
your siteÌtumọ̀ Yorùbá: ’s data according to your own scheme and configure HyperDB
accordingly.

### Is there any advantage to using HyperDB with just one database server?

None that has been measured. HyperDB does at least try again before giving up connecting,
so it might help in cases where the web server is momentarily unable to connect 
to the database server.

One way HyperDB differs from WPDB is that HyperDB does not attempt to connect to
a database until a query is made. Thus a site with sufficiently aggressive persistent
caching could remain read-only accessible despite the database becoming unreachable.

### What if all database servers for a dataset go down?

Since HyperDB attempts a connection only when a query is made, your WordPress installation
will not kill the site with a database error, but will let the code decide what 
to do next on an unsuccessful query. If you want to do something different, like
setting a custom error page or kill the site, you need to define the ‘db_connection_error’
callback in your db-config.php.

## Àwọn àgbéyẹ̀wò

![](https://secure.gravatar.com/avatar/5976c93a3179c9906b451d24fd977e8b53a1c3664f1ec8b3feaa044fb56fc435?
s=60&d=retro&r=g)

### 󠀁[Perfectly does the job with php 8.1](https://wordpress.org/support/topic/excellent-12198/)󠁿

 [fidji](https://profiles.wordpress.org/fidjius/) Ọwẹ́wẹ̀ 30, 2022

HyperDB is a must-have plugin for those with heavy database loads. Thanks for the
php 8.1 update. It is installed on all my WP websites. I use AWS RDS MySQL databases
with 1 writer and 2 readers for all my websites. This plugin perfectly does the 
job! Thank you

![](https://secure.gravatar.com/avatar/0ce739df567bef88be92b80191bb6d7311c4633ba9bf7b68330c27210d07713f?
s=60&d=retro&r=g)

### 󠀁[Excellent](https://wordpress.org/support/topic/excellent-9793/)󠁿

 [Shane](https://profiles.wordpress.org/shanemarsh28/) Ọ̀wàrà 5, 2020

We use this with AWS RDS and read replicas. Please keep maintaining and keep up 
the great work.

![](https://secure.gravatar.com/avatar/4e22fde5b20ce70334982fecbb571b1aa231d69681597b37b40ecd325236146c?
s=60&d=retro&r=g)

### 󠀁[A hidden gem](https://wordpress.org/support/topic/a-hidden-gem-5/)󠁿

 [Haris](https://profiles.wordpress.org/harisrozak/) Ọ̀wàrà 2, 2020

Maybe this plugin is not so popular because many WordPress users are just not technical
users, but I truly glad the plugin is here, and hopefully the WordPress team still
always have a time to maintenance this 🙂 Kudos!

![](https://secure.gravatar.com/avatar/f39dc86d143ce16ef52009438c0bf2983a393e390fe465fa5894143e26bfc214?
s=60&d=retro&r=g)

### 󠀁[I had high hopes](https://wordpress.org/support/topic/i-had-high-hopes-2/)󠁿

 [pipermp3](https://profiles.wordpress.org/pipermp3/) Òkúdù 10, 2020 1 ìdáhùn

Plugin seems outdated. And before anyone goes “Can you even read? You didnt follow
the readme” yes I did. So to recap Ìtumọ̀ Yorùbá: – Downloaded the .zip on separate
machine Ìtumọ̀ Yorùbá: – Unpacked Ìtumọ̀ Yorùbá: – Opened Readme Ìtumọ̀ Yorùbá: –
Opened db-config and according to the db-config itself, it uses the definitions 
from wp-config.php, so actually according to the file no changes is technically 
required. Ìtumọ̀ Yorùbá: – moved db.config.php into root web directory next to wp-
config. Ìtumọ̀ Yorùbá: – moved db.php into wp-content. Ìtumọ̀ Yorùbá: — Attempted
first-time install (page appeared) On step=2 there are tons of Wordpress Database
errors indicating “bad default value” for pretty much everything. Therefore unable
to first-time login as Admin, as the admin user was not successfully put into the
DB by HyperDB itself. The db.config contained a singular configured DB (localhost)
and yes, both read/write as 1. Wordpress works excellently when the plugin is taken
out and these insert errors only appears when db.php and db.config is present in
their corresponding folders. Somewhat likely the plugin here is outdated for the
newer versions of Wordpress/Mysql.

![](https://secure.gravatar.com/avatar/518cc8b557d6219a85f4e7cb856d049d5ebd1fd99d3d7ec112dabba33f78d9f8?
s=60&d=retro&r=g)

### 󠀁[Works very well with RDS and read Replica](https://wordpress.org/support/topic/works-very-well-with-rds-and-read-replica/)󠁿

 [rafasashi](https://profiles.wordpress.org/rafasashi/) Bélú 11, 2019

This plugin works very well with AWS RDS and read replica.

![](https://secure.gravatar.com/avatar/5663014b76b796e987e70d9628d1adbb791cbb44b9c5a9f4d800920c0d676701?
s=60&d=retro&r=g)

### 󠀁[Works perfectly](https://wordpress.org/support/topic/works-perfectly-1487/)󠁿

 [SoN9ne](https://profiles.wordpress.org/son9ne/) Ògún 13, 2018

This plugin works as described and perfectly for my AWS Aurora Writer/Reader setup.

 [ Ka gbogbo àwọn àgbéyẹ̀wò 14 ](https://wordpress.org/support/plugin/hyperdb/reviews/)

## Àwọn Olùkópa & Olùgbéejáde

“HyperDB” jẹ́ ètò ìṣàmúlò orísun ṣíṣí sílẹ̀. Àwọn ènìyàn wọ̀nyí ti ṣe ìkópa sí plugin
yìí.

Àwọn Olùkópa

 *   [ Automattic ](https://profiles.wordpress.org/automattic/)
 *   [ Matt Mullenweg ](https://profiles.wordpress.org/matt/)
 *   [ Andy Skelton ](https://profiles.wordpress.org/andy/)
 *   [ Ryan Boren ](https://profiles.wordpress.org/ryan/)
 *   [ Michael Adams (mdawaffe) ](https://profiles.wordpress.org/mdawaffe/)
 *   [ vnsavage ](https://profiles.wordpress.org/vnsavage/)
 *   [ Barry ](https://profiles.wordpress.org/barry/)
 *   [ Peter Westwood ](https://profiles.wordpress.org/westi/)
 *   [ WordPress VIP ](https://profiles.wordpress.org/wpcomvip/)

[Túmọ̀ “HyperDB” sí èdè rẹ.](https://translate.wordpress.org/projects/wp-plugins/hyperdb)

### Ṣe o nífẹ̀ẹ́ sí ìdàgbàsókè?

[Ṣàwárí koodu](https://plugins.trac.wordpress.org/browser/hyperdb/), ṣàyẹ̀wò [ibi ìpamọ́ SVN](https://plugins.svn.wordpress.org/hyperdb/),
tàbí ṣe àgbékalẹ̀ sí [àkọsílẹ̀ ìdàgbàsókè](https://plugins.trac.wordpress.org/log/hyperdb/)
nípasẹ̀ [RSS](https://plugins.trac.wordpress.org/log/hyperdb/?limit=100&mode=stop_on_copy&format=rss).

## Àkọsílẹ̀ àwọn àyípadà

#### 1.9

 * Restore the behavior where we retry failed connection attempts to masters;
 * Unbreak the logic for marking servers as down Ìtumọ̀ Yorùbá: – in r2625068 the
   key for marking server as down was mistakenly changed to “server_readonly_$host
   $port” instead of “server_state_$host$port”
 * If all masters are marked as read-only, ignore the read-only flag and still try
   to connect; otherwise we might end up incorrectly breaking the master connections
   for 2 minutes (APCu cache time) if we had temporarily set read-only on them;
 * Fix a bug where having $dbhname in the server state keys can delay marking server
   as down or read_only by doing it once for all possible datasets and operations
   instead of once for the host+port;
 * Fix a bug where we could mark server as read-only even though the ER_OPTION_PREVENTS_STATEMENT
   error was returned for a different reason; now we match to make sure we actually
   have ‘read-only’ in the returned error;
 * Fix a bug where the correct tracking of the unique read-only servers or lagged
   slaves might fail if we have duplicate servers for the same dataset;
 * Fix a bug where we would not mark masters as read-only in HyperDB if they were
   set read-only on the server side after we already opened a connection;
 * Fix a bug where we might stop respecting the minimum configured amount of retries
   per dataset;
 * Revert the persistent unused_servers logic which was added in HyperDB 1.8 because:
   it can cause connection failures when the available servers are exhausted, we
   might use servers with wrong priorities, and not see newly added servers to HyperDB.
   Some examples of conditions which would trigger these behaviors include: server-
   side disconnects on timeout; when we manually disconnect open connections in 
   long-running scripts; when we switch between different datasets on the same remote
   MySQL server; weÌtumọ̀ Yorùbá: ’ve gone over the configured max_connections and
   started disconnecting existing connections to accomodate new ones;
 * Make sure the read_only and the downed logic still works in environments which
   donÌtumọ̀ Yorùbá: ’t have APCu or APCu is badly fragmented by adding local caching
 * Correct the dbh property type
 * PHP 8.0 compatibility for call_user_func_array() and db_connections attribute

#### 1.8

 * Support for fallback master connections
 * Add support for marking servers read-only
 * Fix the issue when `do_action()` is not available
 * Use APCu to cache the results of server responsiveness
 * Add support for the `utf8mb4` server capability

#### 1.7

 * Add support for information_schema and transactions
 * Requires WordPress 4.2 for wpdb::get_table_from_query()

#### 1.6

 * Add support for MYSQL_CLIENT_FLAGS which was added to wpdb in [21609]
 * Fix PHP 7.3 Notice

#### 1.5

 * Fix WordPress 4.8.3 SQLi vulnerability
 * Add action for SQL logging
 * Never db_connect for SELECT FOUND_ROWS()
 * Better cleanup when disconnecing db connections

#### 1.4

 * Additional logging for HyperDB failures and do not save “null” queries.

#### 1.3

 * Improved failed query tracking

#### 1.2

 * PHP7 compatability
 * MySQLi support
 * Allow utf8mb4 character set

#### 1.1

 * Extended callbacks functionality
 * Added connection error callback
 * Added replication lag detection support

#### 1.0

 * Removed support for WPMU and BackPress.
 * New class with inheritance: hyperdb extends wpdb.
 * New instantiation scheme: $wpdb = new hyperdb(); then include config. No more
   $db_* globals.
 * New configuration file name (db-config.php) and logic for locating it. (ABSPATH,
   dirname(ABSPATH), or pre-defined)
 * Added fallback to wpdb in case database config not found.
 * Renamed servers to databases in config in an attempt to reduce ambiguity.
 * Added config interface functions to hyperdb: add_database, add_table, add_callback.
 * Refactored db_server array to simplify finding a server.
 * Removed native support for datacenters and partitions. The same effects are accomplished
   by read/write parameters and dataset names.
 * Removed preg pattern support from $db_tables. Use callbacks instead.
 * Removed delay between connection retries and avoid immediate retry of same server
   when others are available to try.
 * Added connection stats.
 * Added save_query_callback for custom debug logging.
 * Refined SRTM granularity. Now only send reads to masters when the written table
   is involved.
 * Improved connection reuse logic and added mysql_ping to recover from “server 
   has gone away”.
 * Added min_tries to configure the minimum number of connection attempts before
   bailing.
 * Added WPDB_PATH constant. Define this if youÌtumọ̀ Yorùbá: ’d rather not use 
   ABSPATH . WPINC . ‘/wp-db.php’.

## Àkójọpọ̀ Meta

 *  Ẹ̀yà **1.8**
 *  Ìgbàgbọ́hùn tó kẹ́yìn **ọdún 4 sẹ́yìn**
 *  Àwọn ìgbéwọlẹ̀ tó ṣiṣẹ́ **10+**
 *  Ẹ̀yà WordPress ** 4.2 tàbí ju bẹ́ẹ̀ lọ **
 *  Dánwò dé **6.0.12**
 *  Èdè
 * [English (US)](https://wordpress.org/plugins/hyperdb/)
 * Àwọn àmì
 * [availability](https://yor.wordpress.org/plugins/tags/availability/)[mysql](https://yor.wordpress.org/plugins/tags/mysql/)
   [performance](https://yor.wordpress.org/plugins/tags/performance/)[scaling](https://yor.wordpress.org/plugins/tags/scaling/)
   [WordPress.com](https://yor.wordpress.org/plugins/tags/wordpress-com/)
 *  [Ìwòye Tó Péye](https://yor.wordpress.org/plugins/hyperdb/advanced/)

## Àwọn ìbò

 4.1 lára àwọn ìràwọ̀ 5.

 *  [  11 5-star reviews     ](https://wordpress.org/support/plugin/hyperdb/reviews/?filter=5)
 *  [  0 4-star reviews     ](https://wordpress.org/support/plugin/hyperdb/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/hyperdb/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/hyperdb/reviews/?filter=2)
 *  [  3 1-star reviews     ](https://wordpress.org/support/plugin/hyperdb/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/hyperdb/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/hyperdb/reviews/)

## Àwọn Olùkópa

 *   [ Automattic ](https://profiles.wordpress.org/automattic/)
 *   [ Matt Mullenweg ](https://profiles.wordpress.org/matt/)
 *   [ Andy Skelton ](https://profiles.wordpress.org/andy/)
 *   [ Ryan Boren ](https://profiles.wordpress.org/ryan/)
 *   [ Michael Adams (mdawaffe) ](https://profiles.wordpress.org/mdawaffe/)
 *   [ vnsavage ](https://profiles.wordpress.org/vnsavage/)
 *   [ Barry ](https://profiles.wordpress.org/barry/)
 *   [ Peter Westwood ](https://profiles.wordpress.org/westi/)
 *   [ WordPress VIP ](https://profiles.wordpress.org/wpcomvip/)

## Ìrànlọ́wọ́

Nǹkan wà tí o fẹ́ sọ? Ṣé o nílò ìrànlọ́wọ́?

 [Wo àpéjọ ìrànlọ́wọ́](https://wordpress.org/support/plugin/hyperdb/)