mysqldump数据库备份还原语句
在mysql中我们的数据备份与还原都是用到了mysqldump命令来操作,下面给大家简单总结一下。
目前 MySQL 支持的免费备份工具有:mysqldump、mysqlhotcopy,还可以用 SQL 语法进行备份:BACKUP TABLE 或者 SELECT INTO OUTFILE,又或者备份二进制日志(binlog),还可以是直接拷贝数据文件和相关的配置文件。MyISAM 表是保存成文件的形式,因此相对比较容易备份,上面提到的几种方法都可以使用。Innodb 所有的表都保存在同一个数据文件 ibdata1 中(也可能是多个文件,或者是独立的表空间文件),相对来说比较不好备份,免费的方案可以是拷贝数据文件、备份 binlog,或者用 mysqldump。
代码如下 | 复制代码 |
|
注释:
将数据库school备份到school.bbb文件,school.bbb是一个文本文件,文件名任取,打开看看你会
有新发现。
备份MySQL数据库的命令
代码如下 | 复制代码 |
mysqldump -hhostname -uusername -ppassword databasename > backupfile.sql |
备份MySQL数据库为带删除表的格式
备份MySQL数据库为带删除表的格式,能够让该备份覆盖已有数据库而不需要手动删除原有数据库。
代码如下 | 复制代码 |
mysqldump -–add-drop-table -uusername -ppassword databasename > backupfile.sql |
直接将MySQL数据库压缩备份
代码如下 | 复制代码 |
mysqldump -hhostname -uusername -ppassword databasename | gzip > backupfile.sql.gz |
备份MySQL数据库某个(些)表
代码如下 | 复制代码 |
mysqldump -hhostname -uusername -ppassword databasename specific_table1 specific_table2 > backupfile.sql |
同时备份多个MySQL数据库
代码如下 | 复制代码 |
mysqldump -hhostname -uusername -ppassword –databases databasename1 databasename2 databasename3 > multibackupfile.sql |
仅仅备份数据库结构
mysqldump –no-data –databases databasename1 databasename2 databasename3 > structurebackupfile.sql备份
服务器上所有数据库
代码如下 | 复制代码 |
mysqldump –all-databases > allbackupfile.sql |
还原MySQL数据库的命令
代码如下 | 复制代码 |
mysql -hhostname -uusername -ppassword databasename |
还原压缩的MySQL数据库
代码如下 | 复制代码 |
gunzip |
将数据库转移到新服务器
代码如下 | 复制代码 |
mysqldump -uusername -ppassword databasename | mysql –host=*.*.*.* -C databasename |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

When we use win7 system, sometimes we accidentally drag the taskbar to the left or right, which looks very uncomfortable and affects the use. In fact, the restoration method is very simple. Just drag it back or change the settings in the properties. Let’s take a look. Restore the win7 taskbar to the following tutorial method one: 1. First, right-click the taskbar and make sure the taskbar is not locked. If it is locked, click Unlock. 2. Left-click an empty space on the taskbar, hold down the left mouse button, and drag downwards to drag the taskbar back. 3. It should be noted that due to the screen size, dragging the taskbar will change the size of the taskbar. Move the mouse to the edge of the taskbar and drag up or down to set the appropriate size. square

PHP and PDO: How to perform database backup and restore operations When developing web applications, database backup and restore are very important tasks. As a popular server-side scripting language, PHP provides a wealth of libraries and extensions, among which PDO (PHP Data Objects) is a powerful database access abstraction layer. This article will introduce how to use PHP and PDO to perform database backup and restore operations. Step 1: Connect to the database Before actual operation, we need to establish a connection to the database. Use PDO pair

In the current Internet era, the importance of data is self-evident. As one of the core components of Internet applications, database backup and recovery work is particularly important. However, as the amount of data continues to increase and business requirements become increasingly complex, traditional database backup and recovery solutions can no longer meet the high availability and high performance requirements of modern applications. Therefore, optimizing the backup and recovery performance of MySQL database has become an urgent problem that needs to be solved. In practice, we have adopted a series of project experiences to effectively improve MySQL data

In the process of developing business systems, the database is a very important part. Therefore, backing up and restoring the database is a very necessary operation. This article will combine examples of the ThinkPHP6 framework to introduce how to use ThinkPHP6 to implement database backup and recovery. 1. Database backup 1.1 Environment preparation Before performing database backup, you need to confirm the following points: 1. You need to set the bin directory address of the mysql database and add its path to the system Path variable; 2. Mysqld needs to be installed

With the rapid development of the Internet, large-scale MySQL database backup and recovery has become one of the essential skills for major enterprises and websites. With the widespread application of Memcached, how to back up and restore Memcached has also become an important issue. As one of the main languages for web development, PHP has unique advantages and skills in handling backup and recovery of MySQL and Memcached. This article will introduce in detail the implementation method of PHP processing MySQL and Memcached backup and recovery.

Backing up your database in Golang is crucial to protecting your data. You can use the database/sql package in the standard library, or a third-party package such as github.com/go-sql-driver/mysql. Specific steps include: Connect to the database. Create a file to store the backup data. Use the Dump function or Exporter to back up the database to a file.

The bak file is a file format used in AutoCAD software to back up DWG files. When we accidentally delete or damage the original DWG file, we can use the bak file to restore it. This article will introduce how to restore dwg files using bak files. 1. Find the location of the bak file and the source DWG file. First, we need to find the location where the bak file and the source DWG file are stored. Normally, the bak file will be saved in the same folder as the DWG file. If you can't find it, you can try Win
