If you cannot back up a MySQL or PostgreSQL database every day, you should back up the database once a week. For many enterprises, database information represents the website content and other important data. Therefore, it is very important to maintain data backup. Fortunately, both MySQL and PostgreSQL provide
If you cannot back up a MySQL or PostgreSQL database every day, you should back up the database once a week. For many enterprises, database information represents the website content and other important data. Therefore, it is very important to maintain data backup. Fortunately, both MySQL and PostgreSQL provide
If you cannot back up a MySQL or PostgreSQL database every day, you should back up the database once a week. For many enterprises, database information represents the website content and other important data. Therefore, it is very important to maintain data backup.
Fortunately, both MySQL and PostgreSQL provide tools to convert the database into a flat-text file, so that you can enter the database information to another system or back up the database and keep it.
To back up a MySQL data, you can use the mysqldump tool. For example, to back up a database named data, you can perform the following operations:
$ Mysqldump-u webuser -- password = pass data> data. dump
Generally, mysqldump adopts the standard format. You should rewrite this standard format into a file name (in this example, write data. dump ). The only drawback of this automatic backup method is that the password must be specified on the command line.
To back up a PostgreSQL database, you can use the pg_dump tool. The user accessing the database needs to run this tool. According to the host access rules stipulated by PostgreSQL, you may not need to enter a password for the database to obtain the database information. The procedure is as follows:
$ Pg_dump data> data. dump
This is the same as the mysqldump tool, but the latter does not require user names or passwords, because you are running this tool as a user with the permission to access the database.
In the two database backup methods, the generated output file provides instructions for re-creating the entire database. Therefore, this output file contains the data and table structure, which is the necessary information for creating a database.
You can also use other command lines to obtain the data you want to save through the preceding two types of commands. For these two commands, you can log on to the website and read all the operation information, and customize your database backup operations.