一、准备.sql文件 二、在命令行下登录到MySQL数据库下,创建数据库。
- nii@mmch:~/lanqq/code$ mysql -uroot -p //登录到数据库
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 2
- Server version: 5.6.25-0ubuntu0.15.04.1 (Ubuntu)
- Copyright (c) 2000, 2015, 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> CREATE DATABASE test_db; //创建数据库表test_db
- Query OK, 1 row affected (0.42 sec)
- mysql> USE test_db; //默认数据库更改为test_db
- Database changed
- mysql> source /home/nii/code/qq.sql; //导入qq.sql文件
- Query OK, 0 rows affected (0.32 sec)
- Query OK, 0 rows affected (0.09 sec)
- Query OK, 0 rows affected (0.09 sec)
- Query OK, 0 rows affected (0.12 sec)
- Query OK, 0 rows affected (0.09 sec)
- Query OK, 0 rows affected (0.02 sec) //导入成功
复制代码
三、查看数据库是否导入成功。 |