1and1 Help Centre Categories

print article

Import a MySQL Database Using SSH

For Linux packages with SSH access
Step 1
You will have to be logged into your server via SSH.
Step 2
Once logged in, type the
pwd
command and press ENTER to print working directory. 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.
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!
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.
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
For 1&1 Managed Server packages the command will be:
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.
For additional information, you may want to reference: