大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
MySQLdump -uroot -pabc123 --databases school > /opt/school.sql
创新互联公司成立于2013年,我们提供高端重庆网站建设、成都网站制作公司、成都网站设计公司、网站定制、成都营销网站建设、小程序制作、微信公众号开发、seo优化服务,提供专业营销思路、内容策划、视觉设计、程序开发来完成项目落地,为成都围栏护栏企业提供源源不断的流量和订单咨询。
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