|
Web Contractors Web Developer Jobs Join Us / Log in Discussion |
How to archive and restore MySQL with gzip
I'm always using these commands to move databases around from production to staging server and to commit to the repository. I'm always forgetting them too so I might as well paste it here for me to remember and help others... Aren't I nice!
To backup your MySQL database to a gzip file you run this in your command line thingy:
mysqldump -u myusername -p mydbname | gzip > myfile.sql.gz
You need to change the: myusername mydbname and myfile.sql.gz to your settings
To restore you do this:
gunzip < myfile.sql.gz | mysql -u myusername -p mydbname
To copy mysql tables from one database to another:
mysqldump -u myusername -p mydatabase mytablename | mysql -u myusername destinationdatabase;
If you're logged into MySQL from the command line you can restore like this:
mysql> source myfile.sql
New forum topics
- [MELB] Web Developer | Web Designer | Graphic Designer | Marketing Manager
- Open Source Online Invoicing Software
- Professional Drupal Consulting, Design & Development Services in Australia
- New Year Speacial-Professional Website for 400$ with doamin+Host
- Ruby on Rails Oceana
- WebDev/Design/Research/Consultant - PHP/MySql, Javascript, Joomla, HTML, Flash, AJAX
- Freelance ASP.NET Developer
- System Monitoring with Nagios
- Learning Ruby? What about the RubyMentor Project?
- Need a team
- JAOO Sydney/Brisbane 2009
- Get Your Business a Website for $399 ONLY !!!
- Concrete5: Another CMS!
- Manage The Cloud with Amazon Web Services
- Crystal Reports developer needed


Thanks
Thanks for that. It worked a treat.
To import from MySQL
mysql> source file_name
mysql> \. file_name
Post new comment