Recently I migrated to a shared hosting connection for my entire website, one of the problems I encountered was that it broken all of the links to my MySQL databases
When I moved the directories and files, all I was consistently receiving was database connection not available.
The problem you have with shared hosting is that all the MySQL databases must be separated. So to do this, all hosting providers give your MySQL database a leading connection.
In the form of myself, my host gives all my database names andrewho_ (then the database name)
For my databases, they were called wordpress and zencart.
My new MySQL databases are called andrewho_wordpress and andrewho_zencart. The problem is you need to repair the connection when migrating to shared hosting connection with wordpress and it’s actually really easy
Here is how to fix the SQL database problems
1) Carry out an SQL dump of the entire database
You need to back up your entire existing database, for me it was hosted on my home PC. I had the MySQL Workbench installed, so it’s just a case of selecting the “Export” option, ticking your database. Giving it a name to identify it (ending in .sql) and saving to your computer
2) Create a new database from your hosting provider for the directory where you want to install it
Your wordpress needs to be reimported with phpmyadmin to recreate all the tables and data
3) Modify your .SQL file (so it doesn’t create a new database)
One of the major problems I encountered was every time I uploaded the file, it failed. This was because my user account didn’t have permissions to create databases with the names given by the SQL files. This is because you need to reimport the data with a modified SQL file using the new details
The quick way of doing this is to open your SQL file with Notepad++ or any text editor and comment out the lines and change the database names. I have given an example of this below so it’s easier to explain.
MY EXISTING SQL FILE INFORMATION
CREATE DATABASE IF NOT EXISTS `wordpress` /*!40100 DEFAULT CHARACTER SET latin1 */;
MY NEW SQL FILE INFORMATION
Note the highlighted entries, you need to comment out (–) the option to “create” the database… in this example it wants to create a database called “wordpress” (it’s already created)
— CREATE DATABASE IF NOT EXISTS `wordpress` /*!40100 DEFAULT CHARACTER SET latin1 */;
Originally it was called “wordpress”, you need to change the database name so it knows where to import the data
I had to modify both my files when uploading the data other wise it break the database.
4) Once you have uploaded the files, you need to modify the wp-config.php file otherwise it will just try fail to connect to the database. This is in the following directory
Here is an example of the details on my directory…..
// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
/** MySQL database username */
define(‘DB_USER’, ‘andrewho_myusername (eg root, admin)‘);
/** MySQL database password */
define(‘DB_PASSWORD’, ‘My secret password‘);
/** MySQL hostname */
Views – 866