In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you how to back up the MySql database, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. Shortcut to data backup
Since this method has not been verified by official documents, let's call it an experiment.
Purpose: to back up a mysql database TestA in the hostA host and restore it to the hostB machine
Test environment:
Operating system: WinNT4.0,Mysql3.22.34,phpMyAdmin 2.1.0
Install mysql database and establish TestA database in hostA
Host B machine installs mysql database, no TestA database
Methods and steps:
Start phpMyAdmin to view the list of databases in HostA and HostB. There is no TestA database in HostB.
Locate the installation directory of mysql in HostA and find the database directory data
In my experimental environment, this catalog is
C:mysqldata
Find the subdirectory of the corresponding database name
C:mysqldataTestA
Paste and copy to the Data directory of HostB. The HostA is the same as the files in the HostB Mysql data directory.
Refresh the phpMyAdmin of HostB and take a look at the database list. We can see that TestA has appeared, and the operations such as query modification are normal, and the backup recovery is successful.
Conclusion: the database of Mysql can be saved, backed up and restored in the form of files, as long as the corresponding file directory is restored, and there is no need to use other tools to back up.
Second, formal methods (official recommendations):
To export the mysqldump tool to be used with MySQL, the basic usage is:
Mysqldump [OPTIONS] database [tables]
If you do not specify any tables, the entire database will be exported.
By executing mysqldump-help, you can get a list of options supported by your version of mysqldump.
Note that if you run mysqldump without the-quick or-- opt option, mysqldump will load the entire result set into memory before exporting the results, which may be a problem if you are exporting a large database.
Mysqldump supports the following options:
-- add-locks
Add LOCK TABLES before each table is exported and then UNLOCK TABLE. (for faster insertion into the MySQL).
-- add-drop-table
Add a drop table before each create statement.
-- allow-keywords
Allows you to create column names that are keywords. This is done by adding the table name before the column name.
-c,-- complete-insert
Use the full insert statement (with column names).
-C,-- compress
If both the client and the server support compression, compress all the information between them.
-- delayed
Insert a row with the INSERT DELAYED command.
-e-- extended-insert
Use the new multiline INSERT syntax. (give more compact and faster insert statements)
-#,-- debug [= option_string]
Track the use of the program (for debugging).
-- help
Displays a help message and exits.
-- fields-terminated-by=...
-- fields-enclosed-by=...
-- fields-optionally-enclosed-by=...
-- fields-escaped-by=...
-- fields-terminated-by=...
These choices are used with the-T selection and have the same meaning as the corresponding LOAD DATA INFILE clause.
LOAD DATA INFILE syntax.
-F,-- flush-logs
Wash out the log files in the MySQL server before starting the export.
-f,-- force
Even if we get a SQL error during a table export, continue.
-h,-- host=..
Export data from a MySQL server on a named host. The default host is localhost.
-l,-- lock-tables.
Lock all tables to start the export.
-t,-- no-create-info
Do not write table creation information (CREATE TABLE statement)
-d,-- no-data
No row information is written to the table. This is useful if you only want to get an export of the structure of a table!
-- opt
Same as-- quick-- add-drop-table-- add-locks-- extended-insert-- lock-tables.
Should give you the fastest possible export for reading into a MySQL server.
-pyour_pass,-- password [= your_pass]
The password used to connect to the server. If you do not specify the "= your_pass" section, mysqldump requires a password from the terminal.
-P port_num,-- port=port_num
The TCP/IP port number used when connecting to a host. (this is used to connect to a host other than localhost because it uses Unix sockets. )
-Q,-- quick
Without buffering the query, export it directly to stdout; and use mysql_use_result () to do it.
S / path/to/socket,-- socket=/path/to/socket
The socket file used when connecting to localhost, which is the default host.
-T,-- tab=path-to-some-directory
For each given table, create a table_name.sql file that contains SQL CREATE commands, and a table_name.txt file that contains data. Note: this only works if mysqldump is running on the same machine as the mysqld daemon. The format of the .txt file is based on the-- fields-xxx and-- lines--xxx options.
-u user_name-- user=user_name
The user name used by MySQL when connecting to the server. The default is your Unix login.
-O var=option,-- set-variable var=option
Sets the value of a variable. Possible variables are listed below.
-v,-- verbose
Lengthy mode. Print out more information about what the program does.
-V-- version
Print version information and exit.
-W,-- where='where-condition'
Export only selected records; note that quotation marks are mandatory!
"--where=user='jimf'"- wuserid > 1"- wuserid
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.