Magento – Magento 1 can’t connect to database

databaseerrormagento-1.9

Please Helpme on this,I have copied a live site to a development environment so I can do some testing. I've followed this tutorial to get everything up and running.

When I go to the site is says that there has been an error. The log says the following: "SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

I have multiple other magento instances running on the same machine and they all work. The database is on a different machine.

My local.xml is all correct and when I create a simple php test page which contains the following:

<?php
      $mysqli=mysqli_connect("[same data as local.xml]");
      if(mysqli_connect_errno()){
          printf("Connect failed: %s\n", mysqli_connect_error());
          exit();
      }else{
          echo "Connection succesfull!";
      }
?>

The page is returning: Connection succesfull!

I've tried: restarting apache2 and php5-fpm, clearing cache and session folder, removing the other .xml files in /app/etc except local.xml and config.xml.

Can somebody help me fix this problem?
Thanks in advance!

see link

Best Answer

  1. Check for the correctness of your entry made in app/etc/local.xml
  2. Check in the table "core_config_data" for if there is a correct entry for the row of secure and insecure base-URL
  3. Try to replace the .htaccess file present at the root with the .htaccess file which comes with the bare Magento version of your Magento site
Related Topic