hugo-teek is loading...

备份mysql数据

最后更新于:

新机器

 1mysql -u root -p
 2
 3
 4show databases;
 5
 6
 7
 8##删除数据库
 9mysql> show databases;
10+--------------------+
11| Database           |
12+--------------------+
13| information_schema |
14| LikeGirlv520       |
15| mysql              |
16| performance_schema |
17| sys                |
18+--------------------+
195 rows in set (0.02 sec)
20
21mysql> drop database LikeGirlv520;
22Query OK, 11 rows affected (0.04 sec)
23
24mysql> 

老机器

 1##检查
 2mysql> SHOW DATABASES;
 3+--------------------+
 4| Database           |
 5+--------------------+
 6| information_schema |
 7| LikeGirlv520       |
 8| mysql              |
 9| performance_schema |
10| sys                |
11+--------------------+
125 rows in set (0.00 sec)
13
14mysql> USE LikeGirlv520;
15Reading table information for completion of table and column names
16You can turn off this feature to get a quicker startup with -A
17
18Database changed
19mysql> SHOW TABLES;
20+------------------------+
21| Tables_in_LikeGirlv520 |
22+------------------------+
23| IPerror                |
24| about                  |
25| article                |
26| diySet                 |
27| leavSet                |
28| leaving                |
29| login                  |
30| loveImg                |
31| lovelist               |
32| text                   |
33| warning                |
34+------------------------+
3511 rows in set (0.00 sec)
36
37mysql> 

备份:

1[root@wiki ~]# mysqldump -u root -p --databases LikeGirlv520 > LikeGirlv520_backup.sql
2Enter password: 
3[root@wiki ~]# ll LikeGirlv520_backup.sql -h
4-rw-r--r-- 1 root root 20K Jun  9 12:32 LikeGirlv520_backup.sql
5[root@wiki ~]# 

新机器

 1[root@localhost ~]#mysql -u root -p < /root/LikeGirlv520_backup.sql
 2Enter password: 
 3
 4
 5mysql> SHOW DATABASES;
 6+--------------------+
 7| Database           |
 8+--------------------+
 9| information_schema |
10| LikeGirlv520       |
11| mysql              |
12| performance_schema |
13| sys                |
14+--------------------+
155 rows in set (0.00 sec)
16
17mysql> USE LikeGirlv520;
18Reading table information for completion of table and column names
19You can turn off this feature to get a quicker startup with -A
20
21Database changed
22mysql> SHOW TABLES;
23+------------------------+
24| Tables_in_LikeGirlv520 |
25+------------------------+
26| IPerror                |
27| about                  |
28| article                |
29| diySet                 |
30| leavSet                |
31| leaving                |
32| login                  |
33| loveImg                |
34| lovelist               |
35| text                   |
36| warning                |
37+------------------------+
3811 rows in set (0.00 sec)
39
40mysql> 

验证

本次,经实际测试,这个方式是可以正常备份项目数据的,完美。😜

image-20250613211943742

推荐使用微信支付
微信支付二维码
推荐使用支付宝
支付宝二维码
最新文章

文档导航