EN
EspañolEnglishFrançaisDeutschPortuguêsItaliano
Sign in Start free
Lightsail

How to create a managed database in Lightsail and connect your website to it

Move the database off your Lightsail machine to a managed database (MySQL or PostgreSQL) that Amazon maintains and backs up for you. Creating it, connecting from the machine, changing the website's configuration and what to keep an eye on. For non-technical people.

⏱ 30 minutes ◎ Intermediate level Updated on 26/10/2026

Almost every website keeps its data in a database (MySQL nearly always, PostgreSQL sometimes) that lives inside the same machine. It works, but when the machine goes down, everything goes down; when the disk fills up, it fills up for both; and backups of the database depend on someone making them. A managed database is a database that Amazon installs, updates, backs up every day and monitors for you, on a separate machine you never see. Lightsail offers it at a fixed monthly price, just like its machines.

This guide creates one, connects the website to it and explains how to move the data. If your website is small and a single machine is more than enough, it is not compulsory; if the website matters, it is one of the best decisions you can make.

Before you start: what each thing means

Database
Where the website keeps its data: users, orders, texts. The website reads and writes them constantly.
MySQL and PostgreSQL
The two most widely used database systems on websites. WordPress and most online shops use MySQL (or its cousin MariaDB).
Managed database
A database that the provider installs and maintains for you, on a machine you do not administer. You just use it.
Endpoint
The address your website connects to in order to talk to the database. It replaces the "localhost" from when it was on the same machine.
Master user
The main user of the database, with all permissions. You choose its password or Lightsail generates it.
Public mode
Whether the database accepts connections from the internet. Off by default and it should stay that way: only your Lightsail machines in the same region should reach it.
Dump
A file with the entire contents of a database, for moving it from one place to another.

Step by step

  1. Create the database

    In the Lightsail console, Databases tab, Create database. Choose the same region as your machine, the engine (MySQL for WordPress and most others; PostgreSQL if your application asks for it) and the recommended version. Let Lightsail generate the master password or set a long one of your own. Choose the smallest plan to start with, unless you know you need more. Name: bd-web. Create. It takes a few minutes to become available.

  2. Write down the connection details

    Open the database, Connect tab. You will see the endpoint (a long address ending in rds.amazonaws.com), the port (3306 for MySQL, 5432 for PostgreSQL), the master user and a button to show the password. Leave public mode off: your Lightsail machine can reach it without it because they are in the same region.

  3. Check the connection from the machine

    Open your machine's browser terminal and try (MySQL):

    mysql -h TU-PUNTO-DE-ENLACE -u USUARIO -p

    Type the password when prompted. If you get in and see the mysql> prompt, the connection works. Type exit. If the mysql command does not exist, install the client (sudo apt install mysql-client on Ubuntu or Debian).

  4. Copy the data from the current database to the new one

    If the website already has data in the local database, put the website into maintenance mode for a moment and dump them:

    mysqldump -u root -p nombre_bd > copia.sql
    mysql -h TU-PUNTO-DE-ENLACE -u USUARIO -p -e "CREATE DATABASE nombre_bd"
    mysql -h TU-PUNTO-DE-ENLACE -u USUARIO -p nombre_bd < copia.sql

    On a Bitnami machine (Lightsail WordPress) the local user is root and its password is in the bitnami_application_password file or in the application's configuration. The dump takes longer or shorter depending on size; with a normal website, seconds.

  5. Change the website's configuration

    Edit your application's configuration file and change the database server from localhost to the endpoint, and the user and password to those of the managed database. In WordPress it is wp-config.php: the DB_HOST, DB_USER and DB_PASSWORD lines. Save and open the website: it should work just as before. Turn off maintenance mode.

  6. Stop the local database and review the backups

    Once it has been running on the new one for a few days, stop the machine's database service (sudo systemctl disable --now mysql or the Bitnami command) to free up memory. In the managed database, Snapshots tab: Lightsail makes automatic copies daily; you can also create a manual one before important changes. And look at the Metrics tab from time to time: if CPU or connections are at their limit, it is time to move up a plan, which for databases really is done with a button.

What can go wrong

The website says "Error establishing a database connection"

Check the endpoint, user and password in the configuration letter by letter. Then, that the machine and the database are in the same region. And that the database exists inside the server (the CREATE DATABASE from step 4).

I want to connect from my computer with a graphical program

You need to turn on public mode, which opens the database to the internet (protected only by the password). Do it only for as long as you need it and turn it off again, or connect through the machine with an SSH tunnel.

The website is slower than before

The database is now on another machine and every query travels over the network, even if within the same data centre. Normally you do not notice; if you do, the website is making too many queries: a caching plugin usually solves it.

It costs more than having the database on the machine

Yes: it is one more service. What you are buying is that it does not go down with the website, that it has daily backups without anyone having to remember, and that you can grow without reinstalling anything. For a website that earns money, it usually pays off.

In Simplio

In Simplio the Lightsail and RDS databases appear next to your machines, with their status, their endpoint ready to copy, the backups with dates and the metrics. You take a snapshot with a button, and whoever has permission can see it without being able to touch it. If a scheduled backup is not made or the database is at its limit, it emails you.

The same task, in AWS and in Simplio

In the AWS consoleIn Simplio
See the status and backups of the databaseGo into Lightsail, tab by tabThe database next to its machines, with status, backups and metrics on one card
Make a copy before a changeSnapshots tab, create, nameSnapshot button: 1 click
Find out if it is at its limitLook at the Metrics tabEmail alert if CPU or connections spike, or if a backup is missing

Try it free for 15 days See how it works

All of this, without the AWS console

Simplio is a panel to manage your AWS accounts: machines, scheduled copies, databases, domains, email and what AWS charges you, with per-person permissions and two-factor. Nothing installed on your servers.

Start free for 15 days, no card

Already a customer? Customer access.