I have had to do this a lot lately with all the database work I have been doing so I figured I would write this down before I forgot about it.
If you need to restore a database from a .sql file here is the command:
mysql -h hostname -u username -pthepassword databasename < dumpfile.sql
If you need to dump a database to a file (for automated backup purposes) you can use this command:
mysqldump -h hostname -u username -pthepassword databasename > backup-file.sql
These can be very helpful when doing database work
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.