Select Category
Sitemap Help Contact
print article

Back Up Your MySQL Database Using SSH

For packages with SSH access.

Follow the steps below to backup your MySQL Database and store the backup in your webspace via SSH.

If your package does not have SSH access, then you will need to Backup Your Database Using phpMyAdmin.

Step 2
Once logged in, type the pwd command and press ENTER to print working directory (or more simply, to display which folder you are currently in). The entire folder structure will be displayed. In this article, the current working directory is a joomla subfolder of the webspace.
(uiserver):u12345678:~/joomla > pwd
Step 3
Type cd ~ command and press ENTER to change directory to the root of your webspace. The root of your webspace is the htdocs folder. Type the pwd command and press ENTER again to confirm you are in the htdocs folder.
(uiserver):u12345678:~/joomla > cd ~
(uiserver):u12345678:~ > pwd
Step 4
Next will we create a folder to store all of your MySQL backups in one place. Type mkdir exportedDatabases to make a subfolder in htdocs/ named exportedDatabases/. Next, type cd exportedDatabases/ to change directories to the newly created folder.
Please note:
Using SSH, you can use the Tab key on your keyboard to auto-complete existing file and folder names. Try typing "cd export" without the quotes and then hit the Tab key on your keyboard!
(uiserver):u12345678:~ > mkdir exportDatabases
(uiserver):u12345678:~ > cd exportDatabases/
(uiserver):u12345678:~/exportedDatabases >
Step 5
Now that you are in the folder where you wish to save the exported database file, you can run the export command. The command will be different depending on whether you have a Web Hosting package or a 1&1 Managed Server package.

For Shared Hosting Packages

The command will be similar to:

(uiserver):u12345678:~/exportedDatabases > mysqldump --no-create-db=true -h -u dbo298362073 -p db298362073 >

After typing the above command, hit ENTER. You will be prompted for a password. Please type the password (as you type, the characters will not display on the screen, this is normal) and hit Enter.

Further Explanation:
  • mysqldump: This is the MySQL export command.
  • --no-create-db=true: This is an option to remove the CREATE DATABASE line from being included in the exported file. This is necessary if you plan to import this database file into your (or another) 1&1 MySQL database.
  • -h This is the Host Name where your database is located (available from the 1&1 Control Panel).
  • -u dbo111111111: This is the User Name for your database (available from the 1&1 Control Panel).
  • -p: This is to prompt for a password. Do not type the password now. You will be asked for the password after you hit ENTER.
  • db111111111: This is the database name.
  • >: This is to specify the database should be saved as a file.
  • This is the filename you will enter to save the exported database as. It is best to include either the database name or the domain and today's date

For Managed Server Packages

The command will be similar to:

(uiserver):u12345678:~/exportedDatabases > mysqldump --no-create-db=true -u dbo298362073 -S /kunden/tmp/mysql5.sock -p db298362073 >
Step 6
When the command prompt returns, the export is finished. Type ls -lah to view the contents of the current directory. You should see your exported file listed along with the filesize.
Further Explanation:
  • ls: This is the list command.
  • -lah: These are three options for the list command meaning list in long format, list all files, and list in human-readable format (this will display file sizes in KB, MB, GB, etc).
(uiserver):u12345678:~/exportedDatabases > ls -lah
drwxr-xr-x  2 u12345678 ftpusers   49 Apr   5 10:34 .
drwxr-xr-x 16 u12345678 ftpusers 4.0K Apr   5 10:34 ..
-rw-r--r--  1 u12345678 ftpusers 377K Apr   5 10:34