|CyberSite.net Knowledge Base|
|How To Import a Large MySQL Database
You should be able to use the Online Manager to handle imports for databases which are less than 16 MB in size without issue.
However, there may be cases where you need to import database data that exceeds 16 MB.
One of the many options you have to handle this task in the Cloud Sites environment is a Perl or Bash script which you can schedule via a Cron job.
Here is an example to assist you with setting this up:
mysql -h DB_HOST -u DB_USER -p'DB_PASSWORD' DB_NAME < /path/to/file/db_restore.sql
Create a new text file and add the above code to it and save it as restore.sh
In the above script, you will need to replace the portions in ALL CAPS with your actual information as follows:
/path/to/file/ This is the absolute path to your files. You can find this path by clicking on Hosting, Cloud Sites, Features, and scrolling down. This will be the "Linux Path" listed there. An example would be: /mnt/target02/123456/www.domain.com (Note, the filename is not included in that path)
DB_HOST - Database Host an example would be mysql5-9.wc1
DB_PASSWORD - the password of the target database
DB_USER - the database username
DB_NAME - the name of the database you are restoring to
Upload this file to your Cloud Site (for security purposes, we recommend keep this file outside your webroot) and create a cron job to schedule the task. Note, for step by step instructions on how to create a cron, Please review this article How_do_I_enable/disable_a_cron_job? [Article not yet available.]
Put the name of the file, which, in our example is restore.sh in the "Command To Run" field. Select Perl as the Command Language and then select the minimum interval in which you wish to run your restore script (5 minutes).
There are logs available in your /logs/ folder each time a cron task is performed and you receive an email confirmation letting you know if the task was successful or not.
Please note: The Cron task has 15 minutes to complete. If the script takes longer than 15 minutes to complete, it will timeout. If this is a problem for you please break up the import into smaller pieces (.sql files) and re-schedule the task as necessary.
For more information on Cron and related tasks, please see the following articles [Articles not yet available.]:
What is a cron job? [Article not yet available.]
How do I enable/disable a cron job? [Article not yet available.]
How do I schedule a cron job? [Article not yet available.]
How do I create a cron job to backup my MySQL database? [Article not yet available.]
BACK TO KNOWLEDGE BASE TABLE OF CONTENT
|Copyright 2011 CyberSite.net, a subsidiary of Group One Communications, Inc., All rights reserved worldwide.