Skip to content

Error establishing a database connection - Lightsail and Wordpress

0

Hi All,

I am new to AWS and using wordpress to manage website. However, after I update some contents and plugins the site got offline and the following message appeared.

-Error establishing a database connection. ( Error message on my front-end site)

-Error establishing a database connection This either means that the username and password information in your wp-config.php file is incorrect or that contact with the database server at localhost:3306 could not be established. This could mean your host’s database server is down. (Error message back end when accessing the admin site)

I tried to check the credentials on bitnami console and seems it’s still the same since I never made manual changes back end. So i’m thinking is not the issue.

I tried to check the database is up and running, however when i check databases under the instances there’s no showing. I believe the db we are using us the default one of AWS.

I tried restratung and following this command, https://docs.bitnami.com/google/infrastructure/mariadb/administration/control-services/.

I’m also thinking we need to upgrade our resources, but i’m not sure if that’s the reason of the issue.

Hoping someone can help me, thank you in advance.

asked a year ago973 views
2 Answers
1
Accepted Answer

Hello.

"localhost:3306", so it seems to be using MySQL installed within Lightsail.
Therefore, you need to check the status of MySQL using Bitnami's command.
Is MySQL running when you execute the command below?

sudo /opt/bitnami/ctlscript.sh status

If it is not started, try starting it with the command below.

sudo /opt/bitnami/ctlscript.sh restart mysql

If you are having trouble starting MySQL or an error occurs during startup, could you please share the error message?

EXPERT
answered a year ago
EXPERT
reviewed a year ago
EXPERT
reviewed a year ago
  • You may also want to try restoring your Lightsail instance from a snapshot. https://docs.aws.amazon.com/lightsail/latest/userguide/understanding-instance-snapshots-in-amazon-lightsail.html

  • I tried the command you provided these are the error message >> sudo opt/bitnami/ctlscript.sh status Cannot find any running daemon to contact. If it is running, make sure you are pointing to the right pid file (/v ar/run/gonit.pid)

    sudo opt/bitnami/ctlscript.sh restart mysql Failed to restart mysql: Cannot find check with id mysql

  • When executing the status check command, the gonit process may be stopped for some reason and the status cannot be obtained, resulting in an error. Therefore, run gonit to reacquire the status.

    sudo gonit
    sudo gonit status
    sudo opt/bitnami/ctlscript.sh status
    sudo /opt/bitnami/ctlscript.sh start
    
  • I did the commands you provided, i got this error message >> Job for bitnami.service failed because the control process exited with error code. See "systemctl status bitnami.service" and "journalctl -xe" for details.

    i tried to check the systemctl status..., this is what shows >> State: degraded Jobs: 0 queued Failed: 1 units Since: Mon 2024-06-10 06:24:57 UTC; 5 days ago CGroup: / ├─user.slice │ └─user-1000.slice │ ├─session-283.scope │ │ ├─19972 sshd: bitnami [priv] │ │ ├─19985 sshd: bitnami@pts/0 │ │ ├─19994 -bash │ │ ├─20285 gonit │ │ ├─20581 systemctl status │ │ └─20582 pager │ └─user@1000.service │ └─init.scope │ ├─19975 /lib/systemd/systemd --user │ └─19977 (sd-pam) ├─init.scope ├─unattended-upgrades.service │ └─591 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal ├─ssh.service │ └─572 /usr/sbin/sshd -D ├─rsyslog.service │ └─510 /usr/sbin/rsyslogd -n -iNONE ├─chrony.service │ ├─541 /usr/sbin/chronyd -F -1 │ └─545 /usr/sbin/chronyd -F -1 ├─bitnami.service

  • Can you start the bitnami service with the following command?

    sudo systemctl restart bitnami.service
    sudo systemctl start bitnami.service
    

    By the way, what kind of error does "journalctl -xe" give? It's probably not a problem with Lightsail itself, so you might want to report it on bitnami's GitHub issue and look for a solution. https://github.com/bitnami/vms/issues

0

Hello, any further information on the error logs? This could help us debug the issue further.

AWS
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.