欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 新闻 > 焦点 > MySQL 官方示例库导入

MySQL 官方示例库导入

2025/1/20 17:54:32 来源:https://blog.csdn.net/qq_43911324/article/details/145241942  浏览:    关键词:MySQL 官方示例库导入

下载 SQL 脚本

MySQL 官方提供了示例数据库,下载地址:MySQL 官方示例数据库下载地址
找到如下图所示 Example Databases:

点击下载对应类型的压缩包即可。

导入数据

解压文件:
在这里插入图片描述
下载完成之后解压完显示如上图三个文件,这里拿 sakila 作为示例:

  • sakila.mwb:workbench 数据模型;
  • sakila-data.sql:表记录信息;
  • sakila-schema.sql:表结构信息。

从控制台进入 MySQL,根据 sakila-schema.sql 文件所在的位置进行导入:

SOURCE E:/sakila-db/sakila-db/sakila-schema.sql;Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected, 1 warning (0.05 sec)Query OK, 1 row affected (0.01 sec)Database changed
Query OK, 0 rows affected (0.18 sec)Query OK, 0 rows affected (0.26 sec)Query OK, 0 rows affected (0.06 sec)Query OK, 0 rows affected (0.07 sec)Query OK, 0 rows affected (0.06 sec)Query OK, 0 rows affected (0.12 sec)Query OK, 0 rows affected (0.12 sec)Query OK, 0 rows affected (0.07 sec)Query OK, 0 rows affected (0.07 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.48 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.01 sec)Query OK, 0 rows affected (0.02 sec)Query OK, 0 rows affected (0.02 sec)Query OK, 0 rows affected (0.12 sec)Query OK, 0 rows affected (0.06 sec)Query OK, 0 rows affected (0.11 sec)Query OK, 0 rows affected (0.13 sec)Query OK, 0 rows affected (0.16 sec)Query OK, 0 rows affected (0.10 sec)Query OK, 0 rows affected (0.02 sec)Query OK, 0 rows affected (0.01 sec)Query OK, 0 rows affected (0.02 sec)Query OK, 0 rows affected (0.07 sec)Query OK, 0 rows affected (0.03 sec)Query OK, 0 rows affected (0.01 sec)Query OK, 0 rows affected (0.02 sec)

查看数据库:

show databases;+--------------------+  
| Database           |  
+--------------------+  
| information_schema |  
| learn_sql_grp      |  
| mysql              |  
| performance_schema |  
| sakila             |  
| sys                |  
+--------------------+  
6 rows in set (0.00 sec)

导入数据:

SOURCE E:/sakila-db/sakila-db/sakila-data.sql;Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Database changed
Query OK, 0 rows affected (0.00 sec)Query OK, 200 rows affected (0.01 sec)
Records: 200  Duplicates: 0  Warnings: 0Query OK, 0 rows affected (0.02 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 603 rows affected (0.18 sec)
Records: 603  Duplicates: 0  Warnings: 0Query OK, 0 rows affected (0.02 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 16 rows affected (0.00 sec)
Records: 16  Duplicates: 0  Warnings: 0Query OK, 0 rows affected (0.06 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 600 rows affected (0.04 sec)
Records: 600  Duplicates: 0  Warnings: 0Query OK, 0 rows affected (0.03 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 109 rows affected (0.00 sec)
Records: 109  Duplicates: 0  Warnings: 0Query OK, 0 rows affected (0.02 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 599 rows affected (0.14 sec)
Records: 599  Duplicates: 0  Warnings: 0Query OK, 0 rows affected (0.01 sec)Query OK, 0 rows affected (0.01 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 1000 rows affected (0.45 sec)
Records: 1000  Duplicates: 0  Warnings: 0Query OK, 0 rows affected (0.05 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 5462 rows affected (0.27 sec)
Records: 5462  Duplicates: 0  Warnings: 0Query OK, 0 rows affected (0.01 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 1000 rows affected (0.04 sec)
Records: 1000  Duplicates: 0  Warnings: 0Query OK, 0 rows affected (0.01 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 4581 rows affected (0.40 sec)
Records: 4581  Duplicates: 0  Warnings: 0Query OK, 0 rows affected (0.03 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 6 rows affected (0.00 sec)
Records: 6  Duplicates: 0  Warnings: 0Query OK, 0 rows affected (0.01 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 14881 rows affected (1.53 sec)
Records: 14881  Duplicates: 0  Warnings: 0Query OK, 1163 rows affected (0.02 sec)
Records: 1163  Duplicates: 0  Warnings: 0Query OK, 0 rows affected (0.03 sec)Query OK, 0 rows affected (0.01 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 12377 rows affected (1.49 sec)
Records: 12377  Duplicates: 0  Warnings: 0Query OK, 3667 rows affected (0.07 sec)
Records: 3667  Duplicates: 0  Warnings: 0Query OK, 0 rows affected (0.04 sec)Query OK, 0 rows affected (0.01 sec)Query OK, 0 rows affected (0.00 sec)
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0Query OK, 0 rows affected (0.01 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)

此时,数据导入操作已经完成,可以查看库中的数据:

USE sakila;SELECT *
FROM actor
LIMIT 10;+----------+------------+--------------+---------------------+
| actor_id | first_name | last_name    | last_update         |
+----------+------------+--------------+---------------------+
|        1 | PENELOPE   | GUINESS      | 2006-02-15 04:34:33 |
|        2 | NICK       | WAHLBERG     | 2006-02-15 04:34:33 |
|        3 | ED         | CHASE        | 2006-02-15 04:34:33 |
|        4 | JENNIFER   | DAVIS        | 2006-02-15 04:34:33 |
|        5 | JOHNNY     | LOLLOBRIGIDA | 2006-02-15 04:34:33 |
|        6 | BETTE      | NICHOLSON    | 2006-02-15 04:34:33 |
|        7 | GRACE      | MOSTEL       | 2006-02-15 04:34:33 |
|        8 | MATTHEW    | JOHANSSON    | 2006-02-15 04:34:33 |
|        9 | JOE        | SWANK        | 2006-02-15 04:34:33 |
|       10 | CHRISTIAN  | GABLE        | 2006-02-15 04:34:33 |
+----------+------------+--------------+---------------------+
10 rows in set (0.00 sec)

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com