您好,登錄后才能下訂單哦!
mysqldump -uroot -pabc123 --databases school > /opt/school.sql
mysql> drop database school;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
mysql> source /opt/school.sql
mysql> show databases; #查看數據庫確認
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| school |
| sys |
+--------------------+
mysqldump -uroot -pabc123 school > /opt/school.sql
mysql> create database school;
mysql> source /opt/school.sql;
mysql> show tables;
+------------------+
| Tables_in_school |
+------------------+
| info |
+------------------+
1 row in set (0.00 sec)mysql> select * from info;
+----+------+-------+
| id | name | score |
+----+------+-------+
| 1 | ll | 88 |
| 2 | tl | 68 |
| 3 | ww | 44 |
| 4 | pw | 55 |
+----+------+-------+
mysql -uroot -pabc123 < /opt/school.sql
mysqldump -uroot -pabc123 school info \> /opt/info.sql
mysql> drop table info;
mysql\> source /opt/info.sql
mysql> show tables;
+------------------+
| Tables_in_school |
+------------------+
| info |
+------------------+與數據庫一樣,也可以不登錄mysql恢復數據表
mysql -uroot -pabc123 school < /opt/info.sql
無論是恢復數據庫還是恢復數據表,都應該先查看一下備份文件,看里面有無自動創建數據庫或數據表的命令,再考慮是否在備份時創建數據庫和數據表!
vim school.sql
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。