- Go to your Cpanel > File Manager and then select all your magento files and then click compress to create a zip file of the magento files.
- Download the zip file by going to http://yourdomainname.com/backup.zip (Replace youdomainname.com with your domain name and backup.zip with the name of your zip file)
- Then go to phpmyadmin and on your left click on the database name and then click Export. Select Custom Export Method and choose Output “Save output to a file “ and then choose Compression “zipped or gzipped” and click Go. This will download the compressed database/mysql dump file.
- On your new host, upload the zip file using ftp (Filezilla) and then go to Cpanel > File Manager and select the zip file that you uploaded and click extract.
- Create a new database on the new host and add the database user to it.
- Magento database makes use of foreign key constraints to ensure database integrity. So if you attempt to import the mysql file that you exported using phpmyadmin you will get errors like
Cannot add or update a child row: a foreign key constraint fails
- So to import the sql file without constraint checking add the following statements at the beginning of the sql file.
SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT; SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS; SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION; SET NAMES utf8; SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO'; SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0;
- At the end of the mysql file add the following statements to enable constraint checking again.
SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT; SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS; SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION; SET SQL_NOTES=@OLD_SQL_NOTES;
- Now you will be able to import the mysql database without getting any errors.
- Update the database details by going to aap > etc >local.xml and update the database name, host, database user and password.
- Finally change the nameservers of your domain to point your domain to the new host and you are done with transferring magento to a new host.
If you need help in transferring/moving your magento website to a new host, hire me on odesk.