[SOLVED] AWS Wordpress database errror after install

#1
Hello,

I am following the LiteSpeed WordPress Quickstart guide but get stuck on step 4. Please see my progress through the guide below. Any help to proceed is appreciated.

Step 1
I launched a WordPress with LiteSpeed Cache (Powered OpenLiteSpeed) Server through the machine image found on AWS.
Version: 5.9
Operation System: Linux/Unix, Ubuntu 20.04 | 64-bit (x86)
Updated: 2/7/22 (American date format)
EC2 instance: t2.nano
Storage: 8GB (GP2 SSD)
[EDIT: now references correct AWS image]

Step 2
I connected to the server by SSH through AWS's cloud console.

Step 3
I followed the interactive script by entering the domain, updating the server and rebooting.

Step 4
I visited the server in a browser expecting to see to the WordPress language selection as indicated by the guide. However, I see the error message Error establishing a database connection.

As this is a vanilla installation of a prepared server image I am surprised to see this error.

Thanks,
new2litespeed
 
Last edited:
#2
This was solved by ensuring WordPress correctly references the database. Note: the following instructions will work for a vanilla ListSpeed Web Server with WordPress launched through AWS. Depending on the exact server setup the following instructions may vary.

Stop the database service
sudo service mysql stop

Create a file which the database can run when it next starts. This file will set the database password for WordPress:
touch /home/ubuntu/mysql-init

Modify the file:
nano /home/ubuntu/mysql-init

Add the following line with a password of your choice:
ALTER USER 'wordpress'@'localhost' IDENTIFIED BY 'YOUR_PASSWORD_HERE';

Then type Ctrl+X to exit the text editor then type y to save.

Start the database service running the prepared file:
mysqld --user=root --init-file=/home/ubuntu/mysql-init

Stop the database service again now the file has been applied by typing Ctrl+C.

Start the database server once again, but in the normal way:
sudo service mysql start

Modify the WordPress config file:
nano /var/www/html/wp-config.php

ensure the DB_HOST is localhost
ensure the DB_NAME is wordpress
ensure the DB_USER is wordpress
ensure the DB_PASSWORD matches the newly created database password

Then type Ctrl+X to exit the text editor then type y to save.

Following these instructions I can now see the WordPress language selection and continue with the guide.
 
Last edited:
#5
Hi everybody, I'd like to "reopen" this thread because I'm experiencing the same issue.
I've deployed and started a new instance of this "WordPress With OpenLiteSpeed and LiteSpeed Cache" AMI. As far as I can see from AWS EC2 panel the new istance initialized without errors, but when I successfully connect to it, logging in by Bitvise SSH Client and by 'ubuntu' user, it starts no script.

I've made two attempts: in the first one, the instance type was m5.large and I faced the problem. Then, after having dropped everything and started again I choosed t3.nano but again, with no luck.

Is there a way to make the interactive script working or to execute manually?
 

Unique_Eric

Administrator
Staff member
#6
Hi @XWLuca
I just launched a fresh WordPress with OpenLiteSpeed and LiteSpeed Cache AMI instance using the same steps as you. The setup script runs successfully, and WordPress also loads fine in the browser.

Did you wait until the Instance Status Checks turned green(in my case, it took 1.5 minute)? If you SSH in before the server is fully ready, some services may not be up yet.
 

Attachments

Top