I recently came across a problem with Joomla and MySQL databases when I was working on a clients website. I generally use a test server to develop Joomla websites, and then upload the final website to my web hosting provider. However, for reasons now forgotten I decided to develop this clients website as a subdomain under my main business website.
I almost always use JoomlaPack (http://extensions.joomla.org/extensions/access-a-security/backup/1606) to backup and restore Joomla websites. If you dont know this utility, go and check it out as it really is a time saver. I used Joomlapack to backup the Joomla site from my business website subdomain and restored it the newly created clients hosting account.
I then noticed that although the Joomlapack restore had worked the database had not copied for some reason and it was referencing the original location. As both of these locations use the same hosting provider, it worked, but obviously was not ideal as my clients website was now tied to my account.
I made a copy of the MySQL database and moved it across to the clients new hosting account, and changing the username and database name within Joomla administration backend. This did not work and I got the following error:
Database Error: Unable to connect to the database:Could not connect to MySQL
As the MySQL user password is different from the original MySQL user password then it can’t log in. Unfortunately Joomla only asks you for the database details including the password when you install Joomla. It is not available (unless i’ve missed it) within the Joomla administration back end. I could have reinstalled Joomla. but at this point I had my heels dug in.
Anyway – For anyone who has any issues like this then here is how I resolved it.
1. I used phpMyAdmin to make a export a copy of the clients Joomla MySQL database.
2. I imported the clients MySQL database in to their hosting account, again using phpMyAdmin.
3 I created a new MySQL database user and associated it with the clients MySQL database (make sure you set the correct user priveleges).
4. I edited the Joomla configuration.php file and changed the following entries to enable Joomla to point to the new database:
- var $user = ‘database user’;
- var $db = ‘database name’;
- var $password = ‘user password’;
I was surprised that $password is stored unencrypted.
