Monday, May 18, 2009

Export/Import data in MYSQL

EXPORT
mysqldump -u<user name>
-p<password> <dbname> > <dbname.sql with file path>
eg. mysqldump -uroot -padmin mydb > /mydb.sql

IMPORT
mysql -u<user name> -p<password> < <dbname.sql>
eg.
mysql -uroot -padmin < /mydb.sql

RUN SQL COMMAND FROM CONSOLE
mysql-u<user name> -p<password> -e "SQL Command"
eg.
mysql-uroot -padmin -e "INSERT
INTO NAME VALUES(10,20,'TEST');"