Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By michaellenahan on
Hello, I got the following error when installing Drupal 7 on 1&1 (1and1) shared hosting.
Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2).
The solution was to go to Advanced Options - Database host on the Drupal "Set up database" page.
Replace localhost with the host name provided by 1&1 in Control Panel > Database Settings.
I thought I would document it in case this is useful for someone else out there.
Comments
Thanks, worked with Godaddy also
Had the same error message on Godaddy and this was the fix.
Just to clarify for others:
In your settings.php file change the database setting 'host' from 'local' to whatever your hosting provider calls it.
Thanks again!
Confirm - it worked in GoDaddy
I had the same error. By adding 'host' as provided by godaddy in Hosting Control Center for the database from 'local' resolved the problem.
Thank you.
on GoDaddy
thanks for the fix
Worked for ipage.com too
I had this same error and a hell of time reinstalling my site after transfering hosts so gave up and tried just a new install and received this error.
Changing in advanced options for the host to "WEBSITENAME.ipagemysql.com", as indicated under their sql page solved this.
Getting an error:#2002
#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)
What do you mean by Advanced Options?
Thank You! Worked for me!
Thank You!
Worked for me!
GoDaddy
If you get this error during installation using a GoDaddy hosting account you'll need to go to the 'advanced settings' at the bottom of the Drupal installation page and:
> paste the MySQL server name you get from your GoDaddy account (for example it'll look like this: data1db.db.4496066.hostedresource.com).
> Overall, everything about the Drupal install is very logical. There are no hidden meanings to what Drupal is asking except for this part if you have GoDaddy hosting account. (Linux hosting that is).
I've changed the database
I've changed the database host from "localhost" to "127.0.0.1" and it works fine for me
It Work
After install uninstalling for about 5 times, finally.
thanks.
Thank You!
Thank You!
Slick
Fixing this was my very first Drupal breakthrough, Thanks michaellenahan!
thanks
@Korte40
This error message had stumped me for ages when trying to install D7 on shared hosting. Delighted to report that your advice worked for me.
Worked for me also
Yes by scrolling down to the Advanced Options I was able to put in the actual hostname of the server (DNS Name) and away it went!
Networksolutions / ip
When installing on Network Solutions shared hosting it worked for me also, using the server's ip, instead of "localhost"
Thank you
Not seeing where you change the local host setting
Hmmm I'm installing Drupal 7.2.2 (Network Solutions) and at the database setup screen the only thing I see under advanced options is:
Database file *
The default entry is: sites/default/files/.ht.sqlite
the text underneath is:"The absolute path to the file where Drupal data will be stored. This must be writable by the web server and should exist outside of the web root."
I don't have an option to change the database hostname or server address.
Am I missing something?
GREAT!!!
Thanks for this saved me alot of time !!!! Problem solved !!
dotCloud
This works for dotCloud too.
Whoda thunk that localhost wouldn't work.
Thanks!
Dan
Thanks!
Worked for me as well. Thank you!
In case you wonder why...
It's probably because the hosting provider doesn't have an alias in place from 127.0.0.1 to localhost. (It's an industry standard address, so not sure why they wouldn't?)
So if you replace "localhost" with "127.0.0.1" you're essentially just taking out the reliance on the missing alias, hence fixing the issue.
Another thanks
Had this problem with a new VPS server and this solved it straight away. Many thanks - lifesaver !
You can probably fix this yourself...
If it's a VPS then you can probably fix this by looking into your DNS if you have time.
Thanks
I did it and it's works perfectly. Thanks
byethost
Thanks a lot! On byethost (from BYET Internet Services), one can see the host name in cPanel X (vistapanel) home page (with in the left sidebar the section Stats, Account Details & Server Information) in the section Databases (in main section) clicking MySQL Databases lead to a page labeled MySQL Databases, in the section Current Databases there's a table which should have the DB name in the column MySQL DB Name, the corresponding column (of the same row) MySQL Host Name contain what should replace the default localhost. Mine was sql300.byethost6.com.
Thanks~
I met this question!