How do I import a large MySQL Database?
You should be able to use the Online Manager (see PHPmyAdmin Database Management Interface) to import databases that are less than 16 MB in size without issue.
However, if you need to import database data that exceeds 16 MB into your Cloud Sites environment, you can use a script which you can schedule via a cron job.
Following is an example to help you set up this script:
#!/bin/sh mysql -h DB_HOST -u DB_USER -p'DB_PASSWORD' DB_NAME < /path/to/file/db_import.sql
- Create a new text file, add the preceding code to it, and save it as restore.sh. In the preceding script, replace the placeholders with your actual information, as follows:
- pathToFile—This is the absolute path to your files. You can find this path by clicking on Hosting > Cloud Sites > Features in the Cloud Sites Control Panel and scrolling down the page. This path is the Linux Path listed there. An example is /mnt/target02/123456/www.domain.com. (Note that the file name is not included in this path.)
- databaseHost - The name of the database host. An example is mysql5-9.wc1.
- databaseUser - The name of the database user.
- databae_Password - The password of the target database.
- databaseName - The name of the database to which you are restoring.
- Upload this file to your Cloud Site (for security purposes, we recommend keep this file outside your webroot) and create a "perl" cron job to schedule the task (the perl option runs shell scripts as well). For instructions on how to create a cron job, see How_do_I_enable/disable_a_cron_job?.
Note: For security purposes, we recommend that you keep this file outside your webroot directory.
- Put the name of the file, which in this example is import.sh, in the "Command To Run" field.
- Select Perl as the Command Language and then select the minimum interval at which you want to run that script (5 minutes is recommended).
Logs are available in your
/logs/folder each time a cron job is performed and you receive an email confirmation informing you if the job was successful or not.
Note: The cron job has 15 minutes to complete. If the script takes longer than 15 minutes to complete, it will time out. If this is a problem for you please break up the import into smaller pieces (several .sql files) and reschedule the job as necessary.
For more information about cron and related tasks, please see the following articles:
© 2014 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License
See license specifics and DISCLAIMER