If you manage several websites or applications, you may need separate databases to store their information. Instead of purchasing a separate server for each project, you can host multiple databases on a single Virtual Private Server (VPS). A VPS provides the resources and control needed to install and manage database services. With the right configuration, you can keep different projects organised while using the same server.

 

Why Host Multiple Databases on One VPS?

Hosting multiple databases on one VPS offers several benefits:

  • Lower costs: Manage multiple projects without purchasing separate servers.
  • Easy management: Maintain all databases from one server.
  • Data separation: Keep website and application data in separate databases.
  • Flexible resources: Manage server resources based on your requirements.

For example, you can host separate databases for a WordPress website, an online store and a custom application.

 

What Do You Need?

Before starting, make sure you have:

  • A VPS with sufficient CPU, RAM and storage.
  • Ubuntu or another supported operating system.
  • MySQL or MariaDB installed.
  • SSH access to your server.

In this example, we use MySQL on Ubuntu.

 

How to Create Multiple Databases

1. Install MySQL

Update your server and install MySQL:

        sudo apt update
sudo apt install mysql-server
 
 

2. Access MySQL

        sudo mysql
 
 

3. Create Separate Databases

Create a database for each project:

        CREATE DATABASE website_db;
CREATE DATABASE store_db;
CREATE DATABASE app_db;
 
 

4. Create Individual Users

Create separate database users with strong passwords:

        CREATE USER 'website_user'@'localhost' IDENTIFIED BY 'StrongPassword1!';
CREATE USER 'store_user'@'localhost' IDENTIFIED BY 'StrongPassword2!';
CREATE USER 'app_user'@'localhost' IDENTIFIED BY 'StrongPassword3!';
 
 

5. Assign Database Permissions

Give each user access only to their assigned database:

        GRANT ALL PRIVILEGES ON website_db.* TO 'website_user'@'localhost';
GRANT ALL PRIVILEGES ON store_db.* TO 'store_user'@'localhost';
GRANT ALL PRIVILEGES ON app_db.* TO 'app_user'@'localhost';

FLUSH PRIVILEGES;
 
 

You can now use these database details in the configuration files of your respective applications.

Important Tips for Managing Multiple Databases

  • Monitor resources: All databases share the VPS resources, so monitor CPU, RAM and storage usage.
  • Create backups: Back up databases regularly and keep copies in a separate location.
  • Secure access: Use strong passwords and avoid exposing database ports publicly unless necessary.
  • Check performance: Monitor database activity and optimise slow queries when needed.
  • Upgrade when required: Increase VPS resources as your websites and applications grow.

 

Host Your Databases with VPSHosting.lk

Hosting multiple databases on one VPS is a practical way to manage different websites and applications from a single server. With proper configuration, security and resource management, you can maintain an organised database environment. VPSHosting.lk offers Linux and Windows VPS solutions with flexible resources for developers, businesses and website owners.

Looking for a VPS to host your databases? Visit VPSHosting.lk and explore the available VPS solutions.