Virtual host MySQL database backup

WBOY
Release: 2016-07-25 08:50:15
Original
1292 people have browsed it

Friends who are proficient in operating mysql database virtual hosts know that the MYSQL backup PHP script is only suitable for virtual host users who do not have MySQL Shell permissions. How to back up and restore virtual host users who have MySQL Shell permissions? Today, the editor is Let’s explain the more common backup and restore methods of virtual host MySQL database.

1. About backup:

When we use MySQL, we generally use MyISAM type tables. This type of table is saved in the file system in the form of a file; while HEAP type tables are saved in memory. The following method is for MyISAM tables.

1.1. Directly copy the database file. First of all, this method is not recommended, because the copied data table is specific to a specific operating system (hardware environment), and moving it to other systems may cause problems. Secondly, when backing up, you need to stop the MYSQL server or lock the corresponding table. Otherwise, if the database happens to be inserted/rewritten during the copy process, it will hang. This is not suitable for servers that require uninterrupted operations. The biggest advantage of this method is that it is convenient and fast. When backing up, you only need to copy all the files in the corresponding database folder of the MYSQL data directory. *.frm describes the structure of the table, *.MYD saves the data records of the table, and *. MYI is the index of the table.

1.2. Use the MySQLDump tool: You can use this program to export the database into a text file in the form of SQL statements, which is convenient for moving to different systems. During restoration, the SQL statements in the file will be executed one by one to rebuild the database. In actual use, enter the command in CMD under WINDOWS or Linux Shell:

mysqldump-u user_name -p database_name --option > path:/xxx.sql; press Enter; user_name is the user name; database_name is the database name; path:/xxx.sql is the path and file name to save the backup file.

Then enter the password and the database will be exported to the .sql file under the specified PATH. Make sure that the user has sufficient permissions to access the corresponding database. --option are some parameters that can be specified during backup. You can refer to the MYSQL official documentation. There are several commonly used options:

--opt——A set of commonly used default options, including --add-drop-table --add-locks --create-options --disable-keys --extended-insert --lock-tables --quick --set -charset

--add-drop-table - DROP the old table first when creating the table, suitable for overwriting the database

--where——Back up some records according to conditions, for example: --where="id<1000'"

The mysqldump tool has quite a lot of parameter functions and needs to be carefully studied.

1.3. Use data backup software: multiple backups

Multi-Backup is a global data protection service brand under Shenzhen Mulang Technology. It is jointly invested by the top international investment institutions IDG and Geek Bang. We provide data encryption, backup protection and recovery migration services; support data protection on local devices or cloud storage.

Compared with traditional backup software, we provide a variety of flexible deployment and usage methods. Customers can use multiple backup clients to protect data on a single device; they can also centrally manage the data of all devices under their name on the web console, up to 10 times at the same time. Manage data protection for tens of thousands of devices. Multi-Backup supports mainstream databases MySQL, SQLserver, Oracle; mainstream file systems; supports personal PCs, workstations, servers, minicomputers, and operating systems from Linux, Windows to AIX; currently Multi-Backup has cooperated with 9 major cloud platform manufacturers in the world, including Alibaba Cloud, Tencent Cloud, Microsoft Cloud, Kingsoft Cloud, UCloud, Qiniu, Amazon Cloud, Baidu Cloud, etc. have conducted in-depth cooperation to protect customers' important data at home and abroad.

1. First, log in to the official website of Multi-Backup and click "Free Trial"

  Virtual host MySQL database backup



2. Select "Database Backup"

  Virtual host MySQL database backup



3. Fill in the corresponding account information according to the prompts, and then click "Connect"

  Virtual host MySQL database backup



At this time, if your account is not authorized, a window will pop up for multiple backups---allowing you to authorize the assigned node IP; the authorization statements have already been written, and you just need to copy them to the control panel of the database

  Virtual host MySQL database backup


Then after the authorization is successful, it will jump to another page

  Virtual host MySQL database backup



Here you can modify the backup frequency and storage location. The number of retained copies can save up to 60 historical records

5 Then, the database starts to be backed up.

  Virtual host MySQL database backup



7. After the backup is successful, the system will automatically remind you by email!

2. About restoration

2.1. For the method of directly copying database files, overwrite the corresponding files back to the data directory to restore.

2.2. For the .SQL file generated by DUMP, you can enter in the mysql command line:

Use target_database; Select the database to be restored, it is best to create an empty . path:/xxx.sql; Restore the specified backup file to the current database.




source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!