Bobcares

AWS lightsail WordPress database | Setup Guide

by | Oct 27, 2022

From this AWS lightsail WordPress database article, our WordPress Support Services will show how to transfer WordPress website data to a MySQL-managed database in Lightsail at Bobcares.

Connecting WordPress to MySQL database in AWS Lightsail

WordPress website data for posts, pages, and users, are stored on the MySQL database that runs on the instance in Amazon Lightsail. If your instance fails, the data will become unrecoverable. To prevent this, you should transfer website data to a MySQL-managed database.

We will show you how to transfer WordPress website data to a MySQL-managed database in Lightsail. Also, how to edit the WordPress configuration (wp-config.php) file on the instance. So that website connects to the managed database and stops connecting to the database running on the instance.

Step 1: Complete the prerequisites

Complete the following prerequisites before getting started:

  • Initially, create a WordPress instance in Lightsail, and make a note that it’s in a running state.
  • Create a MySQL-managed database in Lightsail from the AWS Region as your WordPress instance. This should also in a running state.
  • Next, you need to enable the public mode and data import mode of MySQL-managed database.  You can disable Modes after completing the steps from this guide.

Step 2: Transfer the WordPress database to a MySQL-managed database

Complete the following procedure to transfer your WordPress website data to a MySQL-managed database in Lightsail.

1. Sign in to the Lightsail console.

2. In the Instances tab. Select the browser based SSH client option for the WordPress instance.

3. After the browser based SSH client is connected to the WordPress instance. We need to transfer the data in the bitnami_wordpress database that is on the instance to your MySQL-managed database, from the below command. Here replace DbUserName with the user name of your managed database. Similarly, Replace DbEndpoint with the endpoint address of your managed database.

  • sudo mysqldump -u root --databases bitnami_wordpress --single-transaction --compress --order-by-primary -p$(cat /home/bitnami/bitnami_application_password) | sudo mysql -u DbUserName --host DbEndpoint --password

4. At the prompt SSH screen. Enter the password for your MySQL-managed database. Press Enter. As you type, the password will not show up.

5. If the data was successfully transferred and in case you get an error, confirm that you’re using the correct database username, password, or endpoint, and give a try again.

Step 3: Configure WordPress to connect to MySQL-managed database

Complete the procedure to edit the WordPress configuration file (wp-config.php). So that the website connects to your MySQL-managed database.

In the browser-based SSH client connected to your WordPress instance, you need to create a backup of the wp-config.php file in case something goes wrong.cp /opt/bitnami/wordpress/wp-config.php /opt/bitnami/wordpress/wp-config.php-backup

Enter the below command to open the wp-config.php file using the Nano text editor.nano /opt/bitnami/wordpress/wp-config.php

Scroll down till you get values: DB_USER, DB_PASSWORD, and DB_HOST.Modify the following values:

  • DB_USER — Edit the user name of your MySQL-managed database to match.
  • DB_PASSWORD — Edit with the strong password to match with MySQL-managed database.
  • DB_HOST — Edit the endpoint of your MySQL-managed database. Add :3306 port number at the end of the host address.

Save and exit the text editor.

Enter the following command to restart the web services on your instance.sudo /opt/bitnami/ctlscript.sh restart

You will get the result as syntax OK.

Congratulations! Your WordPress site is now successfully configured to use the MySQL-managed database.

Step 4: Complete the next steps

Once connecting your WordPress website to a MySQL managed database. You should complete these additional steps:

  • Create a snapshot of the WordPress instance.
  • Create a snapshot of the MySQL managed database.
  • Disable the public mode and data import mode of MySQL managed database.

[Looking for a solution to another query? We are just a click away.]

Conclusion

To sum up, your WordPress website is now configured to use the MySQL managed database. Also, how to edit the WordPress configuration (wp-config.php) file on the instance.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF