How do I import a MySQL database using SSH?
Linux Packages with SSH Access Only!
This includes:
|
1&1 Business Pro (Linux) |
1&1 Dual Standard (Linux) |
|
1&1 Professional (Linux) |
1&1 Dual Unlimited (Linux) |
|
1&1 Managed Servers |
1&1 Dual Business (Linux) |
This DOES NOT include:
|
1&1 Beginner |
1&1 Business (Linux) |
|
1&1 Home (Linux) |
|
You can import a backed up database yourself from your webspace using the following steps. If your package does not have SSH access, then you may have to import your database using phpMyAdmin - How do I import a MySQL database using phpMyAdmin?
|
Step 1:
|
You will have to be logged into your server via SSH. For help connecting, please reference:
How do I connect to my webspace via SSH?
How do I connect to my webspace via SSH on a Mac?
|
|
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 FAQ, the current working directory is a joomla subfolder of the webspace.
 |
|
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.
 |
|
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.
 |
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!
|
|

|
|
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.
Further Explaination:
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).
 |
|
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 Website Server package.
For Web Hosting packages
The command will be similar to:
mysql -h db1111.perfora.net -u dbo111111111 -p db111111111 < 1and1help.com-Joomla-Apr.05.2010.sql
Further Explaination:
mysql This is the MySQL command to access your databases
-h db1111.perfora.net 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 Website Server (formerly called managed server) packages
The command is different and will be similar to:
mysql -u dbo111111111 -S /kunden/tmp/mysql5.sock -p db111111111 < 1and1help.com-Joomla-Apr.05.2010.sql
Further Explaination:
For Website 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 Website 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.
 |
|
Step 7:
|
When the command prompt returns, the import is finished.
 |
|