By tbianco on
I'm completely sorry for this but I can't find the answer after searching on google.
I went to install Drupal on my localhost but I keep getting this error:
"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 '/tmp/mysql.sock' (2)."
My database connections are correct. When I'm on my localhost I usually use "root" as the username with no password. I did try creating a new user with a password and still it won't connect.
What am I missing here?
Comments
So the problem came in that I
So the problem came in that I had to type in "127.0.0.1" in the server and not localhost.
Installation Tips For Drupal
If you are new to Drupal, like I was not too long ago, and trying to get it up and running, the current installation instructions aren't the best in the world, especially for beginners. Here are a few guidelines that will get you going. Bear in mind that the learning curve for Drupal is steep. Getting it going is the easy part.
Start Fresh. Throw everything out. Remove all the old Drupal folders, all the Wampp, Xampp, and everything else you downloaded to get things going. If you have Wampp and Xampp both, you have a big problem. Even if one is shut off, they still have files associated with the install, and the first one pointing to server port 80 wins. If you have Xampp, why? Just because you can doesn't mean you should. Xampp is for full-blown PHP coders and not built for a testing server like Wamp. You can't access any Apache modules unless you edit the code in Xampp. Wamp provides a user interface to turn modules on and off, such as memory cache.
Fresh Install Install Wamp. Use the defaults and start the service. Download Drupal. Rename the folder to the name of your site, or create a new folder that is the name of your site and save the download copy for later use...just in case. Navigate to Wamp on your C-drive. Open it. Open the WWW folder. Stick you new folder in it. You're done.
Open Drupal On the lower right-hand side of your computer, locate the green icon and click it. Slide up to the top and open localhost. It will display a full page with all your tools and your website information in Firefox, Click on your website. Follow the installation instructions. You will hit a page where you need to install a database. Shrink Firefox and go to the green icon again and open PHP my admin. Under add a database, type in your site name. Under user type in "root" and leave the password blank. Enable the new database and go back to your Drupal install. Fill in the blanks the same way you did at PHP my admin.
Warning If you didn't remove Wamp or Xampp from the Control Panel and dragged the folder from the hard drive to the trash, your registry is full of files from previous installations. They must be removed before you can proceed. You must also use the alias module in Wamp to add additional sites or each new site will need a new server.
Watch a Few Videos Take some time to learn about Drupal and the modular system it uses, how to manage pages, and how to work with themes. There are lots of videos on the web, and lots of sites that are strictly dedicated to teaching Drupal.
hosts file
Your /etc/hosts file should have a line like 127.0.0.1 localhost.localdomain localhost
otherwise your system can't resolve the domain name.
127.0.0.1 and Localhost
127.0.0.1 is an alias for localhost. They are both the same thing. Chances are the firewall on the machine is blocking the installation if the registry is clean.
In some cases the registry is heavily contaminated if there are multiple instances of a server running. In other words, there can only be one server installed for the program to function correctly. Multiple sites are run from the same server under the alias module that comes with wamp. With that function running, any number of sites can run. But if the system is contaminated with old server installations, and the firewall is blocked, nothing will work properly.
Wamp asks up-front during the install for permission to work through the firewall. A window appears and you are given the choice to select it or not. If for some reason this was overlooked, it needs to be addressed.
A good registry editor that will search the registry files will help to locate all the old Apache, wamp, and mysql files. Delete them all and start fresh. In an extreme case another option is a clean install of the operating system that will also install a fresh registry.
This worked for me. Very
This worked for me. Very strange too, since i have 127.0.0.1 in my hosts file.
I never would have guess. Thanks!