Amazon Lightsail offers dedicated Databases. You can make use of it instead of an on-instance database. It's easy, managed, secure, and most importantly it's not tied to the instance. So, your database will be safe even if instance crashes.
In "Deploy WordPress App to Amazon Lightsail, the database is installed in the instance. In this article, we are to cover the dedicated databases.
⚠️ Warning: Dedicated Lightsail Databases are going to cost $$$. It has a 3-month free tier at this time of writing. Check your plan before creating a database.
So, what are you waiting for? Let's dive right in 🏃♂️
Go to your Amazon Lightsail home page. And then click on the Databases tab.
- (A) Select AWS Region and Availablity Zone (AZ). for me Virginia and Zone A are perfect.
- (B) Choose the Database engine and version. I selected MySQL 8.
- (C) Click on Specify login credentials, and
- (D) Click on Specify the master database name.
- (A) Choose Database username
- (B) Password. I'm okay with the generated password, but you can choose yours.
- (C) The first/master database. You can create more later.
- (D & E) Choose your plan type and the actual plan. You can choose the free-tier option like me.
- (F) Give it a name, and
- (G) Hit the Create database button Your database should be created within a few minutes. Please wait for it until it's Running.
- (A) DB Username
- (B) DB Password
- (C) DB Endpoint
- (D) DB Port
You can SSH into your instance.
Install MySQL using the following command:
sudo apt install mysql-server -y sudo systemctl start mysql.service
And then connect to MySQL:
mysql --host <db_endpoint> --user <db_username> --password
Most modern SQL Client applications (ex TablePlus, MySQL Workbench) have the option to connect Database via SSH. You can connect using that option.
You can update your application's
.env file with Database credentials.
wp-config.php file with the database credentials.
Update your database credential in your application's configuration and/or environment file. Check your application's documentation for that. Or it's custom, you know where to put it.
Thanks for reading the article. Adding dedicated databases to Amazon Lightsail instance is not that hard. You can follow me to get instant updates on my posts. You can also subscribe to my newsletter.