/opt/school.sql 刪除庫 mysql> drop database school; 查看數(shù)據(jù)庫 mysql> show databases;..."/>
您好,登錄后才能下訂單哦!
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; #查看數(shù)據(jù)庫確認
+--------------------+
| 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 |
+------------------+與數(shù)據(jù)庫一樣,也可以不登錄mysql恢復數(shù)據(jù)表
mysql -uroot -pabc123 school < /opt/info.sql
無論是恢復數(shù)據(jù)庫還是恢復數(shù)據(jù)表,都應該先查看一下備份文件,看里面有無自動創(chuàng)建數(shù)據(jù)庫或數(shù)據(jù)表的命令,再考慮是否在備份時創(chuàng)建數(shù)據(jù)庫和數(shù)據(jù)表!
vim school.sql
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。