Organizational Research By

Surprising Reserch Topic

Question:mysqldump-command:how to use mysqldump unix command on command line?


mysqldump

This command is biased towards those developers who use MySQL. I’m positive there are identical commands for other RDBMS. Say you needed to move an entire site with it’s database from one server to another. You’ve tarred up all the files, and you’ve moved them to the new server via scp, but how do you get the database? It’s simple:


mysqldump -uroot -p databasename > dumpfile.sql

You will then be prompted for a password and, depending how large the database is, it may take a few seconds to return you to the command prompt. Substitute the ‘root’ parameter for whatever username has access to the database you are trying to dump. The ‘>’ redirects standard output to standard input and places the dumped data in the file ‘dumpfile.sql’. You can then scp that file to your new server and use the ‘mysql’ command to import the dumpfile.sql contents into whatever new database you want:


mysql -uroot -p newdatabase < dumpfile.sql

The database ‘newdatabase’ must already exist. Notice the reverse ‘< ' redirection operator which will send the contents of the dumpfile.sql file into the database specified.

asked Sep 13, 2013 in Java Interview Questions by anonymous
edited Sep 12, 2013
0 votes
66 views



Related Hot Questions



Government Jobs Opening


...