MySQL学习入门教程:命令行下导入示例数据库

2018-11-3008:50:19数据库教程Comments2,168 views字数 1302阅读模式

学习如何在MySQL命令行下将MySQL示例数据库导入到MySQL数据库服务器中。 在本教程之后,您将yiibaidb示例数据库导入到MySQL服务器中以实践和学习MySQL。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/8399.html

第一步: 从MySQL示例数据库文章中下载示例数据库(yiibaidb)。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/8399.html

第二步: 将下载的文件解压缩到临时文件夹中。为了简单起见,我们将把它解压缩到D:\worksp,如下所示 -文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/8399.html

MySQL学习入门教程:命令行下导入示例数据库文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/8399.html

第三步: 连接到MySQL服务器并创建数据库文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/8399.html

D:\software\mysql-5.7.18-winx64\bin>mysql -hlocalhost -uroot -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 23
Server version: 5.7.9 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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>
Shell

创建数据库 -文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/8399.html

mysql> CREATE DATABASE IF NOT EXISTS yiibaidb DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

mysql> use yiibaidb;
Shell

导入数据 -文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/8399.html

mysql> use yiibaidb;
mysql> source D:/worksp/yiibaidb.sql;
Shell

第四步: 测试导入结果文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/8399.html

mysql> select city,phone,country from `offices`;
+---------------+------------------+-----------+
| city          | phone            | country   |
+---------------+------------------+-----------+
| San Francisco | +1 650 219 4782  | USA       |
| Boston        | +1 215 837 0825  | USA       |
| NYC           | +1 212 555 3000  | USA       |
| Paris         | +33 14 723 4404  | France    |
| Beijing       | +86 33 224 5000  | China     |
| Sydney        | +61 2 9264 2451  | Australia |
| London        | +44 20 7877 2041 | UK        |
+---------------+------------------+-----------+
7 rows in set (0.00 sec)
Shell

在本教程中,我们演示了如何使用MySQL命令行将MySQL示例数据库导入到MySQL数据库服务器中。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/8399.html

  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/sjk/8399.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定