Friday, July 18, 2008

Export and Import MySQL without phpmyadmin through or with shell

You can use an ssh client like putty or terminal (embedded linux) to export and import mysql database into .sql file without phpmyadmin like this

Export
mysqldump -uDBUSERNAME -pDBPASSWORD DBNAME > YOURDB.sql

Import
Go to YOURDB.sql path and then type

cat YOURDB.sql | mysql -uDBUSERNAME -pDBPASSWORD DBNAME

or like this

mysql -uDBUSERNAME -pDBPASSWORD DBNAME < /home/xxxxxx/YOURDB.sql

if your file name still in .sql.gz, go to your YOURDB.sql.gz so type

zcat YOURDB.sql.gz | mysql -uDBUSER -pDBPASSWORD DBNAME

NOTES :
- DBUSERNAME is either something as "root" (without quotes) or a username given by the hoster
- DBPASSWORD means your mysql database password
- DBNAME is your database name
- YOURDB means your database name
- xxxxxx is the name of your home

No comments: