Error establishing a database connection

June 16, 2014 4.4k views
I haven't touched my wordpress site in weeks and its been working fine. Now when I visit it I get: Error establishing a database connection On both the site itself and the admin page of the site. Literally nothing has changed. My database credentials are exactly the same and are correct in the wp-config.php file I have a 1gb droplet -- should I add swap? Is that going to significantly decrease performance? Any help would be greatly appreciated!
1 comment
  • Hi, I have this exact same issue. My wordpress setup was running for a few days, then I was suddenly unable to connect to the database. When I try to restart I get

    $ service mysql restart
    stop: Unknown instance:
    start: Rejected send message, 1 matched rules; type="method_call", sender=":1.41" (uid=1000 pid=8132 comm="start mysql ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init ")
    

    My initial setup was based on https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04

    Not sure what the issue is. Is the problem that my user with uid=1000 doesn't have proper rights to run upstart or something?

    by Justin Ellingwood
    WordPress is the most popular content management system on the web. In this guide, we'll demonstrate how to install and configure it on an Ubuntu 14.04 server.
6 Answers
When I checked status it said stopped/waiting. Restarting it gave me:
start: Rejected send message, 1 matched rules; type="method_call", sender=":1.106" (uid=1000 pid=32707 comm="start mysql ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")
Check to see if the MySQL service is running. I think the command is:
service mysql status
If it is not running, start it with:
service mysql start
then try that
Wait.. whoever you are I love you. It started again. I have no idea why it stopped but you just saved my company (hyperbolically of course)
No worries, when Linux gets low on memory it will kill anything (it often kills mysql, and also can kill your webserver).
Hi you have to do the second step properly in this file.. i had the same issue... https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-12-04
mysql -u root -p

CREATE DATABASE your_database_name;
CREATE USER database_user@localhost;
SET PASSWORD FOR database_user@localhost= PASSWORD("database_password");
GRANT ALL PRIVILEGES ON your_database_name.* TO database_user@localhost IDENTIFIED BY 'database_password';
FLUSH PRIVILEGES;
exit
do all off it step by step..You should get "Query OK, 0 rows affected (0.00 sec)" message each time. what i did wrong was, i forgot to enter my database name in grant permission command. hope it will help you.
by Etel Sverdlov
Wordpress is a free and open source website and blogging tool that uses php and MySQL. It was created in 2003 and has since then expanded to manage 22% of all the new websites created and has over 20,000 plugins to customize its functionality. This tutorial shows how to install Wordpress on a server with LAMP. It is written for Ubuntu 12.04.

I had the same problem happen again today --- now its not starting as quickly as before.

What can I do to my droplet to make sure I never run out of memory?

Have another answer? Share your knowledge.