Home » Php » php – Magento not taking new database details

php – Magento not taking new database details

Posted by: admin July 12, 2020 Leave a comment

Questions:

Just moved a magento installation to a local server so I can do some work on it.

Changed my DB details in /app/etc/local.xml

Cleared cache and session by deleting the /var/cache/* and /var/session/*

Magento still throwing an error saying it can’t connect to the database using [email protected]

This is driving me insane. What might I be missing.

How to&Answers:

I faced the same issue once, that eats my plenty of hours.Finally i found my database was migrated not completely.Database tables count was matched in local and demo server.Because of constraints error part of database was not imported.

SET FOREIGN_KEY_CHECKS=0; // top of your exported sql file

//Your database queries

SET FOREIGN_KEY_CHECKS=1;  // bottom of your exported sql file

Magento community wiki has article about migrating Magento server to server

You can check your database connection by core php mysql connection.create connection file as db.php in root directory and add bellow code with your db configuration and execute this file to check connection exists or not.

example :-

$conn = mysql_connect(“Your_Host”,”User_Name”,”Password”);
if(mysql_select_db(“Your_DB_name”,$conn)) echo “yes”; else echo “no”;

This may be help you.