Note: Please go to docs.rightscale.com to access the current RightScale documentation set. Also, feel free to Chat with us!
Home > Clouds > AWS > AWS FAQs > How do I manually download a MySQL dump file from an S3 bucket?

How do I manually download a MySQL dump file from an S3 bucket?

Background Information

You've created a mysqldump file stored it in an S3 bucket. Now you've launched a MySQL database server and want to manually retrieve your *.sql database that's saved as a *.gz (gzip) file and load it into the running server.

If possible, you should use a published RightScript or Chef recipe to perform this action.  However, you may need to manually perform this operation for development and test purposes.

 


Answer

It is assumed that you have already uploaded your dump file to an S3 bucket.

  • <S3-BUCKET> - The name of the S3 Bucket where the file is stored (e.g., mybucket).
  • <DUMPFILE> - The mysqldump file (e.g., mydump-201104161345.gz). Be sure to include the file extension. The file's permissions must be set to "public-read" so that the file can be accessed.
  • <DBSCHEMA> - The database schema name. (e.g., myschema).

 

SSH into your running server and run the following commands, substituting the variables with your own values:

wget http://<S3-BUCKET>.s3.amazonaws.com/<DUMPFILE>
gunzip <DUMPFILE>
mysqladmin -u root create <DBSCHEMA>
mysql <DBSCHEMA> < <DUMPFILE>

To verify that the mysqldump file was properly fetched from the S3 bucket, you can run the following commands:

Note: The name of the database (DBSCHEMA) is "myschema" in the example below.

# mysql

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| myschema           |
| mysql              |
| test               |
+--------------------+
4 rows in set (0.00 sec)

mysql> use myschema;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+--------------------+
| Tables_in_myschema |
+--------------------+
| phptest            |
+--------------------+
1 row in set (0.00 sec)

mysql> select * from phptest;
+----+-----------+-------------+
| id | firstname | lastname    |
+----+-----------+-------------+
|  1 | John      | Doe         |
|  2 | Greg      | Smith       |
|  3 | Elon      | Johnson     |
|  4 | Dean      | Stevenson   |
+----+-----------+-------------+
4 rows in set (0.00 sec)

mysql> exit

See also

You must to post a comment.
Last modified
21:29, 16 May 2013

Tags

S3

Classifications

This page has no classifications.

Announcements

None


© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.