Drupal: .htaccess Access Deny
August 21, 2014 – 7:59 am | No Comment

In this article I will tell how to forbid access to certain resources for some clients. The instructions will include descriptions of different directives.

Read the full story »
CSS Templates

Contain reviews and news about CSS Templates.

Freebies

Contain freebies such as icons, graphics, headers and images for your websites.

Fun Stuff

Contains other fun stuff for entertainment or interesting site showcase.

How-To

Contain technical elaborations on some specific workarounds or common tweak.

Joomla Templates

Contains reviews and news about Joomla templates.

Home » How-To

Back up of MySQL Databases

Submitted by on November 12, 2010 – 7:59 amNo Comment
If you are working on a web-project that uses MySQL, you might need the following tips. Every project supposes that you will create a backup copy. This is standard method. It is very simple to create a copy of all static HTML and other documents. Creating of MySQL backup is more complex problem. Here are the main difficulties occurring while creating MySQL backup copy.

1. Absence of physical access to database. As a rule, hosting providers allow you working with database through scripts or a special mysql-client but don’t give access to files with MySQL data.

2. Administrator doesn’t know how to make backup.

3. If web-master doesn’t have sufficient skills for working with specialized utilities from MySQL package, you can meet a problem related restrictions of hosting-provider for user accounts. This is true for huge databases.

How to create backup copy of MySQL

There is a software (mysqldump) that allows creating of MySQL backup copies quickly and simple. mysqldump also allows fine adjustment of creating backup copies of database or individual tables. mysqldump would be the main tool for creating backup MySQL.

Let’s view how it works on a simple example. We have a hosting, database DBNAME, host HOST with MySQL server. Login info for server is:  LOGIN, PORT, PASS. We should make dump of DBNAME. Execute this in unix shell:

> mysqldump -uLOGIN -PPORT -hHOST -pPASS DBNAME > dump.txt

When this command is executed in dump.txt file, we have a copy of MySQL-database DBNAME. mysqldump displays the results on your screen. You should redirect output to some file, for example, here ” > dump.txt “.

So, what do mysqldump do? It creates a script of restiring your data. For example, if you had test table in your database, which had test2 integer field and the only record “1111”, then mysqldump will create a script like this:

# MySQL dump 8.14
#
# Host: HOST             Database: DBNAME
#--------------------------------------------------------
# Server version        3.23.39-log

#
# Table structure for table 'test'
#

CREATE TABLE test (
  test2 int(11) default NULL
) TYPE=MyISAM;

#
# Dumping data for table 'test2'
#

INSERT INTO test2 VALUES ('1111');

Thus  mysqldump will describe all your tables and create INSERT-commands for restoring the data in tables. So, we redirect output of mysqldump in a text file. We will use this file for restoring later. Let’s view the process of restoring database from a backup.

We will use a standard mysql program for restoring. For example, we have backup in dump.txt file. We should restore it to a working base. Perform the following:

> mysql -uLOGIN -PPORT -hHOST -pPASS DBNAME < dump.txt

I.e. we force mysql-client to connect to a server and run the script. After this we will have tables and data from he backup in our database.

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.