Knowledgebase

Working with Multiple Databases Print

  • developersgitdeployment, developers, database, restore, troubleshooting, cpanel, backup, migration, woocommerce
  • 0

Several applications, several databases.

THE PRINCIPLE

One database and one database user per application, with privileges only on that database.

WHY

A shared user with access to everything means one application's SQL injection exposes all of them.

It also makes backups, restores and migrations independent. Restoring one application does not affect another.

NAMING

Use a convention making the owner obvious. With the cPanel prefix, something like username_shopdb and username_shopuser.

Keep a note of which application uses which, since prefixed names become hard to distinguish at a dozen databases.

PLAN LIMITS

Shared plans limit the number of databases. Check before building something that needs many.

CONNECTION MANAGEMENT

Each application holds connections. Several applications on one account can exhaust limits.

Close connections properly and avoid opening them unnecessarily.

CROSS-DATABASE QUERIES

Possible where the user has access to both, and usually a sign the data model needs rethinking. It also couples applications that should be independent.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot