-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error Establishing Database Connection (a possible solution to this) #66
Comments
I left everything standard. Applied the cookbook. See this error. Wrapped the cookbook to replace the db host value to |
The user 'wordpressuser' was created in the database with no password. I was able to login without being prompted:
So I updated the password for the 'wordpressuser' by setting to the password value I found in
|
The user 'wordpressuser' was created in the database with no password. I was able to login without being prompted: $ mysql -u wordpressuser mysql> \q So I updated the password for the 'wordpressuser' by setting to the password value I found in /var/www/wordpress/wp-config.php. $ mysql -u wordpressuser mysql> SET PASSWORD FOR 'wordpressuser'@'localhost' = OLD_PASSWORD('PASSWORD_FOUND_IN_WPCONFIG'); mysql> \q $ mysql -u wordpressuser -p http://dev.mysql.com/doc/refman/5.7/en/encryption-functions.html#function_old-password brint/wordpress-cookbook#66
Actually upon further examination it looks like wordpres is still using the USER@'localhost' even if I specified the following
Looking through the cookbooks I found that the database cookbook has the resource responsible for the generation of the user. When I debug and step my way through it it seems to create the correct repair sql here.
Before the connection is closed on the mysql adapter I check to make sure that the user has been created with the password:
It seems that the value is set correctly but then when the execution of the run completes it is no longer present. Which leads me to believe that something is taking place when it comes time to grant permissions to the user. When granting permissions to the user it looks like the database password is necessary again. And because it is missing in the definition in the wordpress::database recipe it essentially clears that password. |
I tried using the nginx recipe of this cookbook today on an ubuntu 14.04 machine and it all installed beautifully. BUT...
When I tried to run Wordpress nothing happened. This turned out to be an easy fix - nginx wasn't running, so I had to type:
This started nginx, even though there was no output from the console.
The second problem I ran into was that on accessing the main web page, I got the error: "Error Establishing Database Connection"
Took me a while to figure out - and after some googling, I came across the cause. Turns out that Wordpress doesn't like the database host being referred to as 'localhost'. Instead, you have to use '127.0.0.1'.
Changing this is quite easy. You have to do this from within your cookbook:
If you are using your own cookbook, you can set the host in recipes/default.rb like this:
or alternatively, you can set it in attributes/default.rb like this (useful if you follow the wrapper cookbook pattern):
This allows everything to work as expected. But I'm curious - does anyone know why using 'localhost' doesn't work?
The text was updated successfully, but these errors were encountered: