Create, import and export mysql database using terminal

1) To Export a database, open up terminal, making sure that you are not logged into MySQL and type
mysqldump -u [username] -p [database name] > [database name].sql
mysqldump -u root -p admin_ghc > admin_ghc.sql

2) To import a database, first create a new blank database in the MySQL shell to serve as a destination for your data.
CREATE DATABASE newdatabase;
mysql -u [username] -p newdatabase < [database name].sql 3) stop the MySQL process /etc/init.d/mysql stop

Leave a Reply

Your email address will not be published. Required fields are marked *