找回密码
 注册
首页 ≡≡网络技术≡≡ 数据库 mysql数据库用source命令导入.sql文件,执行SQL语句 ...

mysql数据库用source命令导入.sql文件,执行SQL语句

灰儿 2017-4-11 16:37:34

一、准备.sql文件

二、在命令行下登录到MySQL数据库下,创建数据库。


  1. nii@mmch:~/lanqq/code$ mysql -uroot -p  //登录到数据库
  2. Enter password:
  3. Welcome to the MySQL monitor.  Commands end with ; or \g.
  4. Your MySQL connection id is 2
  5. Server version: 5.6.25-0ubuntu0.15.04.1 (Ubuntu)

  6. Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.

  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  11. mysql> CREATE DATABASE test_db;  //创建数据库表test_db
  12. Query OK, 1 row affected (0.42 sec)

  13. mysql> USE test_db;   //默认数据库更改为test_db
  14. Database changed
  15. mysql> source /home/nii/code/qq.sql;  //导入qq.sql文件
  16. Query OK, 0 rows affected (0.32 sec)

  17. Query OK, 0 rows affected (0.09 sec)

  18. Query OK, 0 rows affected (0.09 sec)

  19. Query OK, 0 rows affected (0.12 sec)

  20. Query OK, 0 rows affected (0.09 sec)

  21. Query OK, 0 rows affected (0.02 sec)  //导入成功
复制代码

三、查看数据库是否导入成功。

您需要登录后才可以回帖 登录 | 注册
学习中心
站长自定义文字内容,利用碎片时间,随时随地获取优质内容。
Q设计语言 了解更多
Q Design 提供商家设计所需的指导与资源,帮商家快速完成产品设计、降低生产成本。
学习中心
站长自定义文字内容,利用碎片时间,随时随地获取优质内容。
Q设计语言 了解更多
Q Design 提供商家设计所需的指导与资源,帮商家快速完成产品设计、降低生产成本。