背景:
发现导入线上的数据库(数据量很多),用GUI工具发现总是出问题,改为命令后没问题,所以我现在更相信命令行的力量。
1.一般sql中没有数据库创建,因此我们可以用 HeidiSQL先创建数据库
2.选择数据库
- // 账号密码登录数据库,注意用cmd,用git bash发现不行
- C:\Users\Administrator>mysql -u root -p
- Enter password: ****
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 4
- Server version: 5.7.15-log MySQL Community Server (GPL)
-
- Copyright (c) 2000, 2016, 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> show databases;
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | chat_server |
- | doudizhu |
- | mj_game |
- | mj_log |
- | mj_log_template |
- | mmo_demo |
- | mt_gateway |
- | mybatis_db |
- | mysql |
- | npc_server |
- | performance_schema |
- | rj_gateway |
- | rj_server |
- | ry-vue |
- | spring-boot |
- | study_mybatis |
- | sys |
- | test_db |
- | vue-books-project |
- +--------------------+
- 20 rows in set (0.00 sec)
-
- // 使用下数据库
- mysql> use vue-books-project;
- Database changed
3.输入source,然后把sql文件拖入进来,则显示路径
- // 拖入后,注意无需加分号,这里看着有几个打印,但是发现还是能导入进来
- mysql> source D:\8_me\book\vue-books-project.sql
-
- Query OK, 0 rows affected (0.00 sec)
-
- Query OK, 0 rows affected (0.00 sec)
-
- Query OK, 0 rows affected, 1 warning (0.00 sec)
-
- ...
-
- Query OK, 0 rows affected (0.00 sec)
-
- mysql>