I use mysql commands as well. Here's example syntax:
Originally Posted by Will.Spencer
This is ideal if you'd like to migrate a site DB (WordPress, Drupal, etc) and have access to a shell account.
STEP 1: Download/dump your DB contents into a file:
STEP 2: Restore/source your old DB contents to the new DB:
mysqldump -h<yourhostname> -u<dbusername> -p'<enterpasswordhere>' <olddbname> > <thefilenameyouwant>.sql
The command will drop you into mysql. At the mysql prompt enter:
mysql -h<your(new)hostname> -u<dbusername> -p'<enterpasswordhere>' <newdbname>
NOTE: filename.sql is the value for <thefilenameyouwant>.sql
With STEP 2, you should see the contents of your DB file scroll by while it imports. This should allow you to quickly verify your dump has worked without feeling the need to leave the prompt.
NOTE: If you are migrating the site to a new machine/hostname:
After STEP 1 (DB Dump), use a text editor (vi, emacs, etc) to open your newly created file:
You should see something like this:
If your Hostname is changing, do a search and replace to update your hostname in the file. If you are using "localhost" you should be fine. Unless you have a special configuration, the hostname normally only appears at the top.
-- MySQL dump 10.x
-- Host: localhost Database: <olddbname>
-- Server version 5.x.x
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
If your Database name is changing, do a search and replace to update the olddbname to the newdbname. For simple configurations, the database also usually only appears at the top of the file.