MySQLdump -uroot -pabc123 --databases school > /opt/school.sql
創(chuàng)新互聯(lián)公司成立于2013年,我們提供高端重慶網(wǎng)站建設(shè)、成都網(wǎng)站制作公司、成都網(wǎng)站設(shè)計(jì)公司、網(wǎng)站定制、成都營銷網(wǎng)站建設(shè)、小程序制作、微信公眾號(hào)開發(fā)、seo優(yōu)化服務(wù),提供專業(yè)營銷思路、內(nèi)容策劃、視覺設(shè)計(jì)、程序開發(fā)來完成項(xiàng)目落地,為成都圍欄護(hù)欄企業(yè)提供源源不斷的流量和訂單咨詢。
mysql> drop database school;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
mysql> source /opt/school.sql
mysql> show databases; #查看數(shù)據(jù)庫確認(rèn)
+--------------------+
| 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恢復(fù)數(shù)據(jù)表
mysql -uroot -pabc123 school < /opt/info.sql
無論是恢復(fù)數(shù)據(jù)庫還是恢復(fù)數(shù)據(jù)表,都應(yīng)該先查看一下備份文件,看里面有無自動(dòng)創(chuàng)建數(shù)據(jù)庫或數(shù)據(jù)表的命令,再考慮是否在備份時(shí)創(chuàng)建數(shù)據(jù)庫和數(shù)據(jù)表!
vim school.sql