Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Data Export and Import between MYSQL databases

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Source database address: 172.16.1.7

Target database address: 172.16.1.51

Steps:

(1) enter the 172.16.1.7 server and log in to the mysql database mysqldump-uusername-ppassword-A | gzip > bak.sql.gz (2) use the scp command to transfer backup files to the 172.16.1.51 server scp-P22 bak.sql.gz root@172.16.1.51:~ (3) switch to the 172.16.1.51 server Extract the backup file gzip-d bak.sql.gz (4) and import it into the database mysql-uusername-ppassword

< bak.sql (5) 进入数据库 查看导入的数据是否成功导入 mysql -uusername -ppassword show databases 说明: -A 同参数--all-databases,备份所有库,并在备份文件中生成创建库的语句及use语句。这样方便恢复时不用创 建指定数据库。 -B 此参数用于指定多个数据库,同-A参数,生成创建库的语句及use语句。 上文的username 和password 请用真实的用户和密码代替 基本的使用方法总结: 1 导出所有库 mysqldump -uusername -ppassword --all-databases >

All.sql 2 imports all libraries mysql > source all.sql; 3 exports some libraries mysqldump-uusername-ppassword-- databases db1 db2 > db.sql 4 imports some libraries mysql > source db.sql; 5 imports a library mysql-uusername-ppassword db1

< db1.sql; 或 mysql>

Source db1.sql; 6 exports some data tables mysqldump-uusername-ppassword db1 table1 table2 > tb.sql 7 imports some data tables mysql-uusername-ppassword db1

< tb.sql mysql>

User db1;source tb.sql

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report