How to import and export Mysql DB as .mysql file from command line mysql client
In Projects, Often there is a need to Move the database from Server to Another, below is a very simple method of using command line mysql client, which comes in handy.
Lets assume myportal is your project which has lots of tables which need to be exported. Now go to your bin folder of your MySql Server Installation on Windows and
Step1. EXPORT your DB as .mysql file
mysql/bin> mysqldump -u root -p[password] [dbName] > mydumpfile.sql
Step2. COPY the file Over to your new machine
For ease, you can copy .mysql file to your bin folder of installation
Step3. IMPORT your .mysql file to DB
Assuming, that you already have created the db,
mysql/bin > mysql -uroot -p[pwd] [databaseName] < mydumpfile.sql
Once Done , Don’t forget to Create your Old database user back and test it out
That should do the trick
Happy Coding!!
Originally published on careerinjava.com on 2013/08/14
Originally published on careerinjava.com on 2013/08/14
Comments
Post a Comment