Blueherb In solitude, where we are least alone

MySQL 导入导出数据库、表

使用 GUI 软件很好操作,下面介绍命令行操作。

  1. 导出
    cmd 命令

1.1 导出整个数据库

mysqldump -hlocalhost -uroot -p student_db > C:\student_db.sql

1.2 导出单个表

mysqldump -hlocalhost -uroot -p student_db student > C:\student_db_student.sql


2. 导入
 导入时需要先创建数据库,然后再导入。
``` mysql
# cmd 登陆数据库
mysql -hlocalhost -uroot -p
-- MySQL 命令
create database student_db character set utf8 collate utf8_general_ci;
use student_db;
-- 导入数据库
source C:\student_db.sql;
--
-- 也可以这样(同样需要先创建数据库):
mysql -uroot -p student_db < student_db.sql
posted @ 2019-03-14 15:42  Blueherb  阅读(290)  评论(0编辑  收藏  举报