Newest Downloads

Mar.18

  [zenoss@zenoss2 ~]$ python Zenoss_Template_Manager.py -husage: Examples: python Zenoss_Templa...

How to Back up a MySQL database
Database HowTo's - MySQL HowTo's
Written by Allen Sanabria   
Saturday, 09 February 2008 13:29

If you've got a website with a database or a custom database running for your applications, it is imperative that you make regular backups of the database...


Following examples are using mysqldump

    • You can use mysqldump to create a simple backup of your database. Here is an example..mysqldump -u username --password=password databasename > backup.sql
    • username - this is your database username
    • password - this is the password for your database
    • databasename - the name of your database
    • backupfile.sql - the file to which the backup should be written.

    • To backup multiple databases, you will have to do the following example.
    • mysqldump -u test1 --password=pass1 --databases world universe >world_and_universe.sql

    • Now what if we want to back up all of our databases. To do that follow the next example.
    • mysqldump -u test1 --password=pass1 --all-databases >alldb.sql

    • Here we are going to show you another way of backing up a databases and certain tables using the --add-drop-table. This essentially adds a drop table statement before every create statement. The purpose of this is so that it will remove any previous copies of the table before recreating it.
    • This example will add a drop statement before every create statement.
      mysqldump --add-drop-table -u test1 --password=pass1 world > world.sql
    • This statement will add a drop statement before the following tables only.
      mysqldump --add-drop-table -u test1 --password=pass1 Customers world_users world_passwd> world.sql


Add this page to your favorite Social Bookmarking websites
Reddit! Del.icio.us! Mixx! Free and Open Source Software News Google! Live! Facebook! StumbleUpon! Yahoo! Free Joomla PHP extensions, software, information and tutorials.
Comments
Search RSS
Only registered users can write comments!

3.22 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

Last Updated on Wednesday, 14 May 2008 11:50