1.linux下面mysql的导入与导出:
导出:
在linux命令行下:mysqldump -u 用户名 -p 数据库名 表名 > 存入的文件名
[syswj@host ~]$ sudo mysqldump -u syswj -p sysDB stu > stu.sql
Enter password:
[syswj@host ~]$ ls
c++_primer download music public shellScript temp vedio
desktop mianshi myvector python spell_correct test
document minisearch photo review stu.sql test_syscall
[syswj@host ~]$
把数据库的表拷贝到了当前目录下
2.把当前目录下的表导入数据库:
linux命令行:
[syswj@host ~]$ mysql -u syswj -p sysDB <stu.sql
Enter password:
mysql下操作操作:
use database;进入数据库
source 操作:
mysql> show tables;
+-----------------+
| Tables_in_sysDB |
+-----------------+
| student |
+-----------------+
1 row in set (0.01 sec)
mysql> source /home/syswj/stu.sql;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.03 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 1 row affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> show tables;
+-----------------+
| Tables_in_sysDB |
+-----------------+
| stu |
| student |
+-----------------+
2 rows in set (0.00 sec)
mysql>