]> scripts.mit.edu Git - www/raw.git/blob - faq/10.mdwn
Import from TextPattern
[www/raw.git] / faq / 10.mdwn
1 [[!meta title="How can I backup and restore MySQL data?"]]
2 You can back up your SQL data in two ways: via the command-line, or
3 using the phpMyAdmin graphical user interface. Note that phpMyAdmin
4 **cannot import large databases** (to get around this limitation,
5 you can import and export databases using the command-line).
6
7
8 * * * * *
9
10 #### Backing up and restoring with the command-line client
11
12 First,
13 [perform a kerberised ssh to scripts.mit.edu after sshing to an Athena workstation](/faq/41/)
14 (lockername@scripts if your website is in a locker). Then, to
15 export the database:
16
17 **mysqldump** *user+database* **\>** *filename.sql*
18
19 To import a database dump, make sure the database exists (you may
20 need to create it from [sql.mit.edu](http://sql.mit.edu/)) and run
21 the command
22
23 **mysql** *user+database* **<** *filename.sql*
24
25
26 * * * * *
27
28 #### Backing up and restoring with phpMyAdmin
29
30 You can use phpMyAdmin to backup and restore data. However,
31 **importing will not work for large databases**.
32
33 To backup your data using phpMyAdmin:
34
35 1.  Log in to [phpMyAdmin](http://scripts.mit.edu/~sql/phpMyAdmin/)
36     with your
37     [SQL password](/faq/59/accessing-mysql-in-athena-with-mycnf).
38 2.  Select the database or table you want to export (if you want to
39     export just one database or table), and click the link at the
40     top-right labeled **Export**.
41 3.  If a list of databases or tables displays at the top, select
42     the databases or tables you want to export: either use “Select
43     All”, or Ctrl-click / Cmd-click to select multiple items. (There is
44     no need to backup `information_schema`, since this is a read-only
45     system table.)
46 4.  Ensure the export type is “SQL”. Check the “Save as file” box
47     near the bottom, and select “gzipped” if you want to compress your
48     exported data.
49 5.  Click **Go** and save the downloaded file somewhere safe.
50
51 To restore your data using phpMyAdmin:
52
53 1.  Make sure the database that you’re restoring into exists by
54     creating it on the [sql.mit.edu web interface](http://sql.mit.edu/)
55     (not phpMyAdmin) if necessary.
56 2.  Log in to [phpMyAdmin](http://scripts.mit.edu/~sql/phpMyAdmin/)
57     with your
58     [SQL password](/faq/59/accessing-mysql-in-athena-with-mycnf).
59 3.  If you want to import a single database, choose that database
60     from the left menu.
61 4.  Click **Import** at the top.
62 5.  Select the backup you downloaded previously (or any
63     SQL-formatted database dump) and click **Go**.
64
65
66