Databases
The database is where your site keeps its content, users and orders. If it crashes or refuses connections, most pages stop working at once. On WordPress this shows up as the famous “Error establishing a database connection”.
- At a glance
- Group
- Availability
- Mellonbot
- Can fix it
- What it does
- Restarts it and fixes common setting problems.
- Approval
- Always with your OK
What you’ll notice
- 01“Error establishing a database connection”
- 02Pages load without content, or checkout and logins fail
- 03Errors like “Too many connections” in your site’s logs
- 04The site is slow, then stops completely
Why it usually happens
- 01The server ran out of memory and the database was stopped
- 02The disk is full, so the database can’t write
- 03Too many visitors opened more connections than allowed
- 04A settings change or update stopped it from starting
Fix it yourself
How to fix it by hand
Comfortable with a terminal? Here’s what an experienced admin would do. Start with the read-only commands.
- 01
Check whether the database is running
Use mariadb, mysql or postgresql depending on what your site uses.
systemctl status mysql --no-pager - 02
Read its recent logs
Look for “out of memory”, “disk full” or configuration errors.
sudo journalctl -u mysql -n 50 --no-pager - 03
Check for memory kills
If the system killed the database to free memory, it’s logged here.
sudo journalctl -k | grep -i "killed process" - 04
Check free disk space
A full disk stops the database from saving anything.
df -h - 05
Restart the database
After fixing the cause, start it again and reload your site.
sudo systemctl restart mysql && systemctl is-active mysql
With Mellonbot
How Mellonbot fixes it
- Checks that your database is running and accepting connections.
- Finds out why it stopped — memory, disk or settings — and explains it plainly.
- Offers to restart it and fix common setting problems, backing up any file it edits first.
- Emails you on scheduled checks if the database goes down or keeps restarting.
Not sure this is your problem? Ask us →
FAQ
Databases: common questions
How do I fix “Error establishing a database connection”?
First check the database is running. If it isn’t, its logs usually say why — often a lack of memory or disk space. If it is running, the login details in your site’s settings may be wrong.
Will restarting the database lose data?
A normal restart doesn’t lose saved data. Visitors in the middle of something may see an error for a few seconds.
Still have a question?
Every message goes straight to the founder.
Related
Often seen together
Free plan · 100 credits to start
Let Mellonbot look after your website
Create a free account and connect your first site in a few minutes. Upgrade only when you need more.
- No card needed
- Leave any time
Prefer to talk first? Get in touch →
- ✓ 100 credits to start
- ✓ No card needed
- ✓ One command to connect your site
Already have an account? Sign in