Select Category
Sitemap Help Contact
print article

Import Your MySQL Database Using SSH

For packages with SSH access.

Follow the steps below to import a backed up MySQL database from your webspace using SSH.

If your package does not have SSH access, then you may have to Import 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
/kunden/homepages/11/d111111111/htdocs/joomla
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
/kunden/homepages/11/d111111111/htdocs
Step 4
For this example, MySQL backup files are located in a folder named exportedDatabases. Type cd exportedDatabases to change directories into the exportedDatabases/ folder. You may check if you are in the right folder by next, typing the pwd command again.
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:~ > cd exportedDatabases/
(uiserver):u12345678:~/exportedDatabases > pwd /kunden/homepages/11/d111111111/htdocs/exportedDatabases
Step 5
Now that you are in the folder where the backup database files are kept, you will need to check which file is to be imported. Type ls -lah to view the contents of the current directory. You should see your SQL file listed along with the filesize.
  • 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 .
drwx---r-t 16 u12345678 ftpusers 4.0K Apr   5 10:34 ..
-rw-r--r--  1 u12345678 ftpusers 377K Apr   5 10:34 1and1help.com-Joomla-Apr.05.2010.sql
Step 6
Now you can run the import command. The command will be different depending on whether you have a Web Hosting package or a Managed Server package.
For Web Hosting Packages
The command will be similar to:
(uiserver):u12345678:~/exportedDatabases > mysql -h db365838511.db.1and1.com -u dbo365838511 -p db365838511 < 1and1help.com-Joomla-Apr.05.2010.sql
Further Explanation
  • mysql: This is the MySQL command to access your databases
  • -h db365838511.db.1and1.com: 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 a database file should be imported to the database.
  • 1and1help.com-Joomla-Apr.05.2010.sql: This is the filename you will enter to specify which of the files you wish to import.

For Managed Server Packages

The command is different and will be similar to:
(uiserver):u12345678:~/exportedDatabases > mysql -u dbo365838511 -p db365838511 < 1and1help.com-Joomla-Apr.05.2010.sql
Further Explanation
  • For Managed Server packages, MySQL runs on the same server and therefore the Host Name specification is not necessary. By default, a connection will be established internally or to localhost
  • -S /kunden/tmp/mysql5.sock: This option specifies to use the supplied socket in place of the default one. This is necessary for connecting to MySQL5 databases on Managed Server packages.


After typing the correct command above that correlates to your package, hit ENTER. You will be prompted for a password. Please type the password (as you type, the characters typed will not display on the screen, this is normal) and hit ENTER.
(uiserver):u12345678:~/exportedDatabases > mysql -u dbo365838511 -p db365838511 < 1and1help.com-Joomla-Apr.05.2010.sql
Enter password:
Step 7
When the command prompt returns, the import is finished.
(uiserver):u12345678:~/exportedDatabases > mysql -u dbo365838511 -p db365838511 < 1and1help.com-Joomla-Apr.05.2010.sql
Enter password:
(uiserver):u12345678:~/exportedDatabases >

For additional information, you may want to reference: