SQL Life

Mysql复制表结构和数据

时间:2014/11/11 20:54:08  作者:solgle  来源:www.solgle.com  查看:1105  评论:0
内容摘要:[root@solgle-srv solgle]# mysql -u root -pEnter password:圀攀氀挀漀洀攀 to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id ...
尝试Mysql数据导入导出
本文出自:http://www.solgle.com/news/120.html
[root@solgle-srv solgle]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 79
Server version: 5.6.20-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)
 
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql> use solgle;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Database changed
mysql> show tables;
+-------------------------+
| Tables_in_solgle         |
+-------------------------+
| Message           |
| MessageReturns    |
| Network        |
| NetworkReturns |
| SolgleFeature         |
| SolgleIP              |
| SolgleTarget          |
| SolgleTargetReturns   |
| Subdata              |
| Sys_log               |
| Users                   |
+-------------------------+
11 rows in set (0.00 sec)
 
mysql> create table desttable like Users;
Query OK, 0 rows affected (0.13 sec)
 
mysql> show tables;
+-------------------------+
| Tables_in_solgle         |
+-------------------------+
| Message           |
| MessageReturns    |
| Network        |
| NetworkReturns |
| SolgleFeature         |
| SolgleIP              |
| SolgleTarget          |
| SolgleTargetReturns   |
| Subdata              |
| Sys_log               |
| Users                   |
| desttable               |
+-------------------------+
12 rows in set (0.00 sec)
 
mysql> select * from desttable;
Empty set (0.06 sec)
 
mysql> insert into desttable select * from Users;
Query OK, 6 rows affected (0.05 sec)
Records: 6  Duplicates: 0  Warnings: 0
 
mysql> select * from desttable;
+----+-----------+----------+----------------------------------+--------+
| ID | Name      | UserName | Password                         | UserID |
+----+-----------+----------+----------------------------------+--------+
|  1 | zhengsan       | admin    | 96e79218965eb72c92a549dd5a330112 | 110    |
|  2 | liudun        | admin2   | 96e79218965eb72c92a549dd5a330112 | 110    |
|  3 | zhangsan  | admin4   | 96e79218965eb72c92a549dd5a330112 | 110    |
|  4 | zhengsan1      | admin    | 96e79218965eb72c92a549dd5a330112 | 110    |
|  5 | liudun1       | admin2   | 96e79218965eb72c92a549dd5a330112 | 110    |
|  6 | zhangsan1 | admin4   | 96e79218965eb72c92a549dd5a330112 | 110    |
+----+-----------+----------+----------------------------------+--------+
6 rows in set (0.00 sec)
 
mysql> 
 
 
----备份及恢复
[root@solgle-srv ~]# mysqldump -uroot solgle > backup.sql -p
Enter password: 
[root@solgle-srv ~]# ls
Desktop    Downloads  Pictures  Templates  Videos           backup.sql  install.log
Documents  Music      Public    Users.txt  anaconda-ks.cfg  data.sql    install.log.syslog
[root@solgle-srv ~]# 
 
---恢复
root@solgle-srv ~]# mysql -uroot solgle < backup.sql -p
Enter password: 
[root@solgle-srv ~]# 

 
标签:Mysql复制表结构和数据 

出处:solgle
网址:www.solgle.com
相关文章
    相关评论
     img1 img2 img3 img4 img5 img6 img7 img8 img9 img10
    评论者:      验证码:  点击获取验证码
       Copyright © 2013-2028 solgle.com,All rights reserved.[solgle.com] 公安机关备案号:51010802000219
    Email:solgle@solgle.com; weixin:cd1008610000 ICP:蜀ICP备14011070号-1