1

I borked a Joomla site while trying to upgrade to Joomla 3. One of the extensions was not supported and I had to restore my backup, including the backup of the database. Unfortunately, it did not work and I just got mySql errors. I should not have tested it locally instead of trying it on a production site.

Now I am trying to run a copy of the website on my computer locally, with Xampp. Xampp is running Apache and mySql. I've configured MySql according to the instructions at: http://docs.joomla.org/Copying_a_Joomla_website but I am still getting the error:

Database connection error (2): Could not connect to MySQL.Database connection error (2): Could not connect to MySQL.

Suggestions?

1
3

Take a look at your database settings in the file configuration.php in your Joomla root directory, this is the file that connects Joomla with your MySQL database.

When using XAMPP on your computer, the root user (with empty password) usually has access to all your databases.

Try setting the following variables in you configuration.php file:

public $user = 'root';
public $password = '';
public $db = 'DATABASENAME';
public $host = 'localhost';

(leave the rest of the fields as they are for now).

Short explanation:
$host : usually "localhost" when using XAMPP
$user : usually "root" when using XAMPP
$password : usually empty when using XAMPP
$db : The name of the database I assume you imported using a tool like phpmyadmin

1
  • changing the host to localhost on your local machine, instead of using the ubiquitously preferred explicit IP address of your loopback device, worked for me. Jun 3 '15 at 21:10
2

This error means what it means. You have defined some incorrect value for the database connection parameters.

Check your configuration.php file and ensure you have filled in the following variables correctly:

public $user = 'DB_USER';
public $password = 'DB_PASSWORD';
public $db = 'DB_NAME';
public $dbprefix = 'jos32_';

Also ensure that you have assigned your database user to the actual database in PhpMyAdmin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.