Skip to content
NewHost
Menu

Managed MySQL in South Africa - When to Use It and How to Connect

Managed MySQL in South Africa explained - what managed means, when it beats a self-run database, backups and security, and how to connect from Node.js safely.

By NewHost team · · 5 min read

A managed MySQL database is one where the hosting provider runs the database server for you: installation, patching, backups and restores, while you just create tables and connect. For South African apps it makes sense when you would rather spend your time on the product than on database administration, and when you want your data stored in the country, close to your app. This guide explains what "managed" really includes, when you need it, and how to connect safely from Node.js.

What "managed" actually means

Running MySQL yourself on a VPS means you own every layer. With a managed database, the provider takes over the operational work:

Task Self-run on a VPS Managed MySQL
Install and configure MySQL You Provider
Operating system and MySQL security patches You Provider
Automated backups You script and monitor them Provider
Restores You, under pressure Provider or support team
Disk and server monitoring You Provider
Schema design, queries, indexes You You
Application credentials and access You You

The bottom rows never go away. A managed database won't fix a missing index or a query that loads 50,000 rows into memory. What it removes is the undifferentiated work that doesn't make your app better.

When you need managed MySQL

Managed MySQL is usually the right call when:

  • You are a small team without a dedicated database administrator.
  • The data matters - orders, bookings, customer accounts - and losing a day would hurt.
  • You want predictable costs in rand rather than your own hours spent on maintenance.
  • Your app is already hosted on a managed platform, so the database sits close to it.

You might run your own when you need unusual MySQL configuration, specific plugins, or very large dedicated hardware - and you have the skills and time to operate it.

Why location matters for your database

Every query your app makes travels between the app server and the database. A page that runs 20 queries pays that network round trip 20 times. So the database should be in the same region as your app, whatever region that is. If your app and users are in South Africa, a South African database is the natural fit.

Location also simplifies POPIA analysis. POPIA has no general rule that data must stay in South Africa, but storing your primary data locally means you don't need a section 72 transborder assessment for that store. See data residency in South Africa for the details.

Backups - check the fine print

Ask any provider:

  • How often are backups taken, and how long are they kept?
  • Can I take an on-demand backup before a risky migration?
  • How are restores done, and how long do they take?
  • Can I export my data myself (for example with mysqldump)?

On NewHost, databases are backed up with your plan: weekly backups kept for 4 weeks on Starter, daily backups kept 7 days on Developer, and daily backups kept 30 days on Business and Agency. You can also take on-demand backups, and restores are handled by the support team. Keep your own periodic export too - see our backup strategy guide.

Connecting from Node.js

Your provider gives you a host, port, database name, username and password. Store them as environment variables - never in code. The common form is a single connection URL:

DATABASE_URL="mysql://app_user:[email protected]:3306/shop"

If the password contains special characters such as @, : or /, URL-encode them (for example @ becomes %40).

With mysql2

The mysql2 package supports promises and a connection pool. Use placeholders (?) for all values to prevent SQL injection:

import mysql from 'mysql2/promise';

const pool = mysql.createPool({
  uri: process.env.DATABASE_URL,
  connectionLimit: 5,
  waitForConnections: true,
});

export async function findCustomerByEmail(email) {
  const [rows] = await pool.execute(
    'SELECT id, name, email FROM customers WHERE email = ? LIMIT 1',
    [email]
  );
  return rows[0] ?? null;
}

Create the pool once when the app starts and reuse it. Opening a new connection per request is slow and can exhaust the database's connection limit.

With Prisma

If you prefer a typed ORM with migrations, Prisma reads the same DATABASE_URL. Our step-by-step guide covers connecting Node.js to MySQL with Prisma.

Connection pool sizing

Each app instance holds its own pool. Multiply pool size by the number of instances (and by any preview deployments or background workers sharing the database) and keep the total comfortably below the database's connection limit. On smaller plans, a pool of 5 to 10 is usually plenty; more connections rarely make a small app faster.

Security basics

  • Separate users - an app user with only SELECT, INSERT, UPDATE, DELETE on its own database, and a separate user for migrations if you can.
  • Strong, unique passwords, rotated when team members leave.
  • Limit network access to your app servers where the platform allows.
  • Encrypt sensitive columns such as ID numbers at the application level if a leak would be serious.
  • No production data in development or previews - use seeded test data.

MySQL, PostgreSQL or MS SQL?

MySQL is a solid default for web apps, WordPress and most Node.js stacks. PostgreSQL has richer data types and extensions; MS SQL fits .NET shops. NewHost's app plans include MySQL databases (1 on Starter, 3 on Developer, 10 on Business, 40 on Agency), and PostgreSQL or MS SQL can be arranged on request.

Frequently asked questions

What is the difference between managed MySQL and MySQL on shared hosting?

Shared web hosting usually includes MySQL databases for the sites on that account, managed through a control panel. Managed MySQL for apps is the same idea aimed at application workloads, with the database provisioned alongside your app and backups included in the plan.

Can I connect to a managed MySQL database from my laptop?

That depends on the provider's network rules. Many restrict access to their own app servers for security. Check your provider's documentation, and prefer working against a local development database anyway.

How do I migrate an existing MySQL database?

Export it with mysqldump --single-transaction --routines --triggers dbname > dump.sql, then import it into the new database. For large or busy databases, plan a short maintenance window or contact your host for help.

Does managed MySQL scale automatically?

Not necessarily. Most managed databases scale by moving to a bigger plan rather than automatically. Good indexing and efficient queries usually give more headroom than extra hardware.

Need MySQL hosted in Johannesburg next to your app, with automatic backups? See managed databases or compare plans.

Related guides

Ready to launch on NewHost?

Choose a plan and go live today, or tell us what you need and we'll recommend the right setup.