In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Environmental requirements:
1. Logical backup tool mysqldump
two。 Use mysql to restore the database
* * step 1: use mysqldump for logical backup
1) back up all libraries on the MySQL server
Back up all libraries as mysql-all.sql files:
[root@MySQL50] # mysqldump-uroot-p-all-databases > / root/alldb.sql
Enter password:
Back up the db1 and db5 libraries at the same time, and save them as data/db.sql files:
[root@MySQL50] # mysqldump-u root-p-B db1 db5 > mydata/db.sql
Enter password:
View parts of the backup file userdb.sql:
[root@MySQL50 ~] # grep'^ CREATE DATA' mydata/db.sql
CREATE DATABASE /! 32312 IF NOT EXISTS/ db1 /! 40100 DEFAULT CHARACTER SET latin1 /
CREATE DATABASE /! 32312 IF NOT EXISTS/ db5 /! 40100 DEFAULT CHARACTER SET latin1 /
Step 2: use the mysql command to restore databases and tables from a backup
1) create a new library named db1cp
Mysql > create database db1cp
Query OK, 1 row affected (0.09 sec)
[root@MySQL50 ~] # mysqldump-uroot-p db1 > mydata/dbcp1.sql
Enter password:
2) Import backup files and rebuild tables and data in the new library
[root@MySQL50] # mysql-uroot-p db1cp
< mydata/dbcp1.sql Enter password: 3)确认新库正常,启用新库 mysql>Show databases
+-+
| | Database |
+-+
| | information_schema |
| | db1 |
| | db1cp |
| | db5 |
| | mysql |
| | performance_schema |
| | sys |
+-+
7 rows in set (0.00 sec)
Mysql > show tables
+-+
| | Tables_in_db1cp |
+-+
| | T1 |
+-+
1 row in set (0.00 sec)
Mysql > select * from T1
+-+
| | id | name | age | |
+-+
| | 1 | sky | 19 | |
| | 2 | tom | 20 | |
+-+
2 rows in set (0.00 sec)
* * 4) discard or delete old libraries
Ysql > drop database db1
Query OK, 1 row affected (0.18 sec)
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.