Managed MySQL
Run MySQL Community Server on dedicated CPUs with local NVMe, without a server to look after. We take care of provisioning, failover and patch updates, and every connection is encrypted with TLS.
Create a MySQL database
- Go to Databases and click Create database.
- Select MySQL.
- Enter a Name. It must be unique in your organization.
- Select the Data center your servers run in. See Regions.
- Select a Plan.
- Under Nodes, select Primary + 1 replica, so a replica takes over if the primary fails.
- Turn on Allow public access if clients outside your private networks connect to the database.
- Click Create database.
The database is ready when its status reads Running.
Plans
Every node gets the full plan and bills at the plan's price, so a primary with one replica costs twice the plan. Storage is what your data and binary logs can use. We keep extra disk for temporary tables and online schema changes. Traffic over private networks, replication included, is free. See Pricing philosophy for internet egress.
Connect to your database
Open the database and find the hostname, the defaultdb database, the admin user and its password under Connection. Copy database URL gives you a ready-made connection string for your app. To connect from a terminal, set the hostname as DB_HOST:
The database listens on port 3306, and every connection must use TLS. A new database is reachable only from the private networks attached to it. The hostname always points at the current primary, so clients follow a failover by reconnecting.
Allow public access opens port 3306 on the primary's public hostname. Get it with betterstack mysql credentials <name> --availability-zone us-west-2a, in public_uri. Replicas stay private. Restrict who can connect with a firewall. A firewall filters only the public address, not traffic from private networks.
Connection hangs from outside Cloud?
The hostname resolves to a private address, so it works only from your private networks. From the internet, turn on public access and connect to the public hostname.
Rotate credentials
To replace the admin password:
- Click Rotate credentials on the database page.
- Click Rotate credentials to confirm.
The previous password keeps working for 24 hours, and open connections stay up, so roll your clients within that window.
Users and databases
admin owns your data. Create databases and users, and grant them access, with plain SQL:
Triggers, views, stored procedures and online schema changes all work. The server itself stays with us, so a few things work differently:
SET GLOBALandSET PERSISTaren't allowed.LOAD DATA INFILEandLOAD DATA LOCAL INFILEare off. Import withmysql < dump.sql, and export withmysqldump --single-transaction.SHOW GRANTSworks only for the account you're connected as. To check another user's grants, connect as that user.- User names starting with
betterstack_belong to the managed service.
Tables use InnoDB. MyISAM and other storage engines that can't replicate safely are turned off. Give every table a primary key. Tables without one stall replicas once they grow.
Replicas and failover
Replicas run in the same data center and copy the primary asynchronously. They serve read-only traffic.
With at least one replica, failover is automatic. When the primary is unreachable for about 90 seconds, the replica with the most applied transactions becomes the primary and the hostname moves to it, usually within 3 minutes.
Because replication is asynchronous, writes that hadn't reached that replica yet are lost. A database without replicas has no failover and is down until its node recovers.
To switch on purpose, for a disaster recovery drill or a planned move:
- Click Fail over on the database page.
- Click Fail over to confirm.
No committed write is lost, but writes are refused from the moment the primary freezes until clients reconnect to the new one. If the replica doesn't catch up within 60 seconds, the switch is called off and the original primary takes writes again.
Seeing error 1290 after a failover?
The old primary stays reachable and rejects writes with error 1290, --super-read-only. Treat it as a signal to reconnect and re-resolve the hostname, cap the lifetime of pooled connections, and don't cache DNS beyond its 60-second TTL.
Snapshots
Click Take a snapshot on the database page. The database keeps serving while the snapshot is taken, and a restore comes up transactionally consistent. Snapshots outlive the database. To restore one, see Database snapshots.
Rescale and disk usage
To change the plan:
- Click Rescale on the database page.
- Select a Plan and click Rescale database.
With replicas, nodes resize one at a time and clients see a single reconnect. A database without replicas is unavailable for a few minutes. You can move to a smaller plan only if your data fits within 80% of its storage.
When storage fills up, the database protects itself:
Act on the warnings. Once the database is read-only, DELETE, TRUNCATE and DROP TABLE fail too, and rescaling to a bigger plan is the only way out. Writes resume on their own once usage is below 90% of the new plan's storage.
Binary logs count toward storage and are kept for 3 days. A bulk load uses about twice the size of the rows it adds, and deleting the rows afterwards frees only the table's share until the logs expire. Leave room for that when you pick a plan.
Updates
We apply MySQL patch releases automatically. Replicas restart first, then the primary hands over to a replica, so clients see a single reconnect. A database without replicas restarts briefly.
Need help?
Please let us know at hello@betterstack.com.
We're happy to help! 🙏