http://www.modwest.com/help/kb6-241.html
How do I connect to my MySQL database?
mysql -h localhost -u web -p
Before you can use MySQL at all, you need to create a database for yourself on your Control Panel. Once you have created a database, there are a few ways you can connect to it:
* At a shell prompt you type all one 1 single line:
mysql -u DBUSERNAME -h DBSERVER -p DBNAME
with the following replacements of the bolded terms above:
o Replace DBSERVER with the correct database servername for your site.
o Replace DBUSERNAME with your own mysql username.
o Replace DBNAME with your own mysql databasename.
Example:
mysql -u joe -h db.joesmith.com -p joeydb
******************
How do I export and move my database tables between servers or copy databases?
First, see this FAQ about how to create your MySQL database using OnSite.
The first step is to dump out the contents of the database running on the old server. You can do this by using the "mysqldump" command on the old server. This command will create all the sql necessary to recreate all the tables in your database, and is called a "dump". A dump can either be printed to your screen, or if there is a lot of data, the dump can be directed into to a file.
To dump your database from the old host, get a shell prompt there with telnet or ssh, and then type this all on 1 single line:
mysqldump -u DBUSER -p DBNAME > DBNAME.sql
substituting DBUSER with your MySQL username at the old host and DBNAME with your database name from the old host.
You will be prompted for your old host's MySQL password, which will not echo back at you as you type. After you provide the right password, you will have a file in your current directory called DBNAME.sql containing your entire database.
You'll need to get this file moved onto our system by either 1) FTP'ing it down to your own computer and then uploading it from there to your account on our system, or, 2) by moving the file directly from the old host to your account here with the 'ftp' or 'scp' command.
After you have the moved the dumpfile from the old host to your account here, follow these instructions on how to import the dump into your MySQL database running here.
*****************
How do I import a MySQL dumpfile into my database?
After you have dumped out your data into a file as described here, FTP or scp that dump file to the home directory (/) on our system.
Once you have uploaded the dump file to your account here, get a shell prompt on our system using telnet or ssh.
Now import the dump file into MySQL by typing all the following on 1 single line at the shell prompt:
mysql -p -h DBSERVER dbname < dbname.sql
The above assumes that your database name on our system is "dbname" and the dumpfile that you uploaded was named "dbname.sql". Replace those with your correct database name and dumpfile filename. Also replace DBSERVER with your correct database server name.
If you have followed this other FAQ on how to create a .my.cnf preference file, you would not have to type so much when connecting to the MySQL Monitor from the shell prompt. With a proper .my.cnf file you could have imported the dump by just typing this at the shell prompt:
mysql < dbname.sql
import:
mysql -p -h DBSERVER dbname < dbname.sql
export:
mysqldump -u DBUSER -p DBNAME > DBNAME.sql