kettle(五):下载 Sakila数据库

本文详细介绍了如何从MySQL官方网站下载Sakila示例数据库,并提供了在MySQL中安装和配置Sakila数据库的具体步骤。包括解压安装包、使用mysql命令行客户端连接MySQL服务器、执行SQL脚本创建数据库结构及数据填充等过程。同时,针对导入过程中可能出现的错误进行了分析并提供了解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

Step1: 下载 Sakila数据库

参考网址: https://blog.youkuaiyun.com/geekcoder/article/details/8988052

下载地址:https://dev.mysql.com/doc/index-other.html

Step2: MySQL中导入Sakila

To install the Sakila sample database, follow these steps:

 

1.   Extract the installation archive to a temporary locationsuch as D:\ When you unpackthe archive, it creates a directory named sakila-db thatcontains the sakila-schema.sql and sakila-data.sql files.

2.   Connect to the MySQL server using the mysql command-line client with the followingcommand:

3.  shell> mysql -u root -p

Enter yourpassword when prompted. A non-root account can be used as long as the account hasprivileges to create new databases.

4.   Execute the sakila-schema.sql script tocreate the database structure by using the following command:

5.  mysql> SOURCE d:/sakila-db/sakila-schema.sql;

Replace d:/sakila-db with thepath to the sakila-schema.sql file on your system.

Note

On Windows youshould use slashes, rather than backslashes, when executing the SOURCE command.

6.   Execute the sakila-data.sql script topopulate the database structure with the following command:

7.  mysql> SOURCE D:/sakila-db/sakila-data.sql;

Replace d:sakila-db with thepath to the sakila-data.sql file on your system.

8.   Confirm that the sample database is installed correctly.Execute the following statements. You should see output similar to that shownhere.

9.  mysql> USE sakila;

10.Database changed

11.mysql> SHOW TABLES;

12.mysql> SELECT COUNT(*) FROM film;

13.mysql> SELECT COUNT(*) FROM film_text;

发现错误:

 

Select count(*) from film

发现film表的数据为0;

 

解决方法:

  1. 手动打开sakila-data.sql文件;
  2. 搜索其中导入film数据的SQL语句;

  1. 拷贝出这些sql语句,到DBeaver中重新执行;

 

 

按照上面的步骤拷贝SQL到DBeaver中运行,仍然发现这些插入SQL语句没有执行。

为了反映错误,去掉set autocommit=0,再次执行;

 

这是反映了错误信息如下:

因为film的结构中差一个 film_text字段;

修改film的结构;

      重新导入数据即成功。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值