Mysqldump is a command code of mysql. It is often used to back up databases or data tables. Next we will introduce the usage of mysqldump.
Mysqldump is a command code of mysql. It is often used to back up databases or data tables. Next we will introduce the usage of mysqldump.
Backup Data:
The Code is as f
-privilegesTo back up a database named MySQL with the Refresh permission command
--quick mysqldumpYou can retrieve and dump table content by row, or you can retrieve the entire contents of a table and buffer the content in memory before dumping. If you are dump a large table, there may be a problem in the buffer. The--quick option forces the contents of the table to be retrieved and dumped on rows without first buffering the content
| gzipis to compress the content directly.
2.
To restore a database:
The code is as follows
Copy Code
Mysql-h Localhost-u root-p123456 www
To back up a database:
The code is as follows
Copy Code
Mysqldump-h localhost-u root-p123456 www > d:/www2008-2-26.sql
Local:1. Into the MySQL directory under the bin folder: E: Enter;
E:>CD Mysqlbin Carriage return
2. Export database:
MySQL Tutorial dump data structure and database tutorial backup Restore method
Mysqldump output table structure and data a series of SQL commands stored in a text fileC:mysqlbinmysqldump-u
Backing up a database
C:mysqlbinmysqldump-u root-p mydatabase > Mydatabase.sql
We can also choose to output just a table from the database, such as the employee table:
C:mysqlbinmysqldump-u root-p MyDatabase Employe
Restore a database: mysql-h localhost-u root-p123456 Www
Back up a database: mysqldump-h localhost-u root-p123456 www > d:\www2008-2-26.sql
The following is a test in a program
$command = "Mysqldump--opt-h $dbhost-u $dbuser-P $dbpass $dbname | gzip > $backupFile ";
$command = "Mysqldump-h localhost-u root-p123456 gue
this setting increases the file performance, applications that cannot process long file names and computers the use Different code pages might not being able to find the files.---------------------------------------------------------------------------------------------------------GetShortPathName get long file name corresponding to the 8.3 format of the short file name when Windows entered the long file name era, so the DOS era of 8.3 format files are not used,But sometimes the 8.3 format file
Because the database disk space in the work is too small, the database backup file is more, consider from the. SQL backup file to. sql.gz format, so that the backup file is reduced to 10 times times the original, disk tension is still very considerable.Backup command:/usr/local/mysql/bin/mysqldump-r-uroot-pmysql WordPress |gzip >/root/db_back/manual/$curdate/wordpress-$ Curdate.sql.gzRestore command:Gunzip This article is from the "less stubborn" blog
The export data instance is as follows:Note: There are spaces behind-h and no spaces behind-u,-pImport data as follows: PHP uses mysqldump to back up the database (and restore)
MYSQLDUMP backup and restoration MYSQL database mysqldump [OPTIONS] database [tables] If no table is specified, the entire database will be exported. Run mysqldump-hhostname-uusername-ppassword databasename> backupfile. SQL to back up a MySQL database in the format of a table with deletionBacking up a MySQL database is in the format of a table with deletion, so t
Copy codeThe Code is as follows:Mysqldump-u user-p db tab1 tab2> db. SQLRestoreCopy codeThe Code is as follows:Mysql-u user-p db Refer:1. copy backup files: (ensure that the database has no write operations (you can lock the Table). Copying files directly cannot be transplanted to other machines, unless the table you are copying uses the MyISAM storage format.2. mysqldump: mysqldump generates text files tha
Backup data:
The code is as follows
Copy Code
Mysqldump-u User name-p password database name > Xx.sql
When the volume of data is large, you can use gzip compression
The code is as follows
Copy Code
Mysqldump-u User name-p password database name | gzip > XX.sql.gz
Recover data:
The code is as follows
Copy Code
Restore a database: mysql-h localhost-u root-p123456 WwwBacking up a database: mysqldump-h localhost-u root-p123456 www > d:/www2008-2-26.sqlThe following is a test in the program$command = "Mysqldump--opt-h $dbhost-u $dbuser-P $dbpass $dbname | gzip > $backupFile ";$command = "Mysqldump-h localhost-u root-p123456 gues
databasename1 databasename2 databasename3 > Structurebackupfile.sql BackupAll databases on the server
The code is as follows
Copy Code
Mysqldump–all-databases > Allbackupfile.sql
command to restore MySQL database
The code is as follows
Copy Code
Mysql-hhostname-uusername-ppassword DatabaseName
Restoring a compressed MySQL databa
MySQL data backup and recovery we can use MYQL's own tools mysqldump, MySQL to achieve.
MYSQLDUMP supports remote single table backups, single database backups, and all database backups.
= = Backup = =
Note the space, additional parameters please add yourself. If-h-u-p, remote backup needs to specify-H server address
-E indicates export SQL is 20 times times faster than normal inserts for bulk inserts
.png-wh_50 "/>Two. Create experimental dataBecause of the newly built database, there is no data in the log, and a new database and table are created to experiment#创建t1库Create DATABASE T1;#创建tab1表CREATE TABLE T1.TAB1 (ID int primary KEY auto_increment,name varchar (20));#插入两条数据Insert into T1.TAB1 (name) VALUES (' Zhangsan ');Insert into T1.TAB1 (name) VALUES (' Lisi ');Three. Make a full library backup and log backup#进行全库备份 and generate a new logmysqldump-uroot-p123456--flush-logs T1 >/opt/t1_ '
Tags: alter MYS export database MCT trigger restart MYSQLD systemctl Backup restore1. Export the database from MySQL5.7mysqldump --all-databases --triggers --routines --events > db.dump2. Import the database on another serversystemctl stop mysqldrm -rf /var/lib/mysql/*systemctl start mysqldmysql -u root -pmysql> SET SQL_LOG_BIN=0;mysql> ALTER USER [emailprotected]‘localhost‘ IDENTIFIED BY ‘MySQL5.7‘;mysql> SET SQL_LOG_BIN=0;mysql> exitmysql Note: Database versions are consistentMysqldump Backup
1. Various usage instructions
A. The simplest use:
Copy Code code as follows:
Mysqldump-uroot-ppassword [Database name]
> [Dump file]
The above command backs up the specified database to a dump file (dump file), for example:
Copy Code code as follows:
mysqldump-uroot-p123 Test > Test.dump
The generated Test.dump file contains the Build table statement, wh
/mysql" -- fields-enclosed-by = "#" -- fields-optionally-enclosed-by = "#"
-- Fields-escaped-
The fields in the output file ignore the given characters. Used with the -- tab option. it cannot be used with the -- databases or -- all-databases options.
Mysqldump-uroot-p mysql user -- tab = "/home/mysql" -- fields-escaped-by = "#"
-- Flush-logs
Refresh the log before you start exporting.
Note: If you export multiple databases at a time (using options --
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.