MySQL安装示例数据库

时间:2021-11-23 09:31:55

MySQL安装示例数据库

本文档演示如何下载及安装MySQL示例数据库sakila及employees数据库

1. 安装sakila数据库

1.1 下载sakila数据库

wget http://downloads.mysql.com/docs/sakila-db.tar.gz

1.2 解压

# tar zxvf sakila-db.tar.gz
# ll -h sakila-db/
total 3.4M
-rw-r--r--. 3.3M Jul sakila-data.sql --插入语句
-rw-r--r--. 49K Jul sakila.mwb --数据模型
-rw-r--r--. 23K Jul sakila-schema.sql --创建语句

1.3 安装数据库

mysql> source ./sakila-db/sakila-schema.sql
mysql> source ./sakila-db/sakila-data.sql

1.4 检查安装的数据库

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| info |
| move_db |
| mysql |
| mysql3306_data |
| performance_schema |
| sakila |
| sbtest |
| sys |
| test |
| undolog |
+--------------------+
11 rows in set (0.00 sec) mysql> use sakila
Database changed
mysql> show tables;
+----------------------------+
| Tables_in_sakila |
+----------------------------+
| actor |
| actor_info |
| address |
| category |
| city |
| country |
| customer |
| customer_list |
| film |
| film_actor |
| film_category |
| film_list |
| film_text |
| inventory |
| language |
| nicer_but_slower_film_list |
| payment |
| rental |
| sales_by_film_category |
| sales_by_store |
| staff |
| staff_list |
| store |
+----------------------------+
23 rows in set (0.00 sec)

1.5 查看数据模型

MySQL安装示例数据库

2. 安装employees数据库

2.1 下载

# wget https://launchpad.net/test-db/employees-db-1/1.0.5/+download/employees_db-full-1.0.5.tar.bz2

# md5sum employees_db-full-1.0..tar.bz2
08d97b7b6ab87887c434eaa32ae50158 employees_db-full-1.0..tar.bz2

2.2 解压

# tar -jxvf employees_db-full-1.0..tar.bz2
employees_db/load_departments.dump
employees_db/load_dept_emp.dump
employees_db/load_dept_manager.dump
employees_db/load_employees.dump
employees_db/load_salaries.dump
employees_db/load_titles.dump
employees_db/employees.sql
employees_db/employees_partitioned.sql
employees_db/objects.sql
employees_db/test_employees_md5.sql
employees_db/test_employees_sha.sql
employees_db/Changelog
employees_db/README

2.3 安装数据库

mysql> source /data/mysql/mysql3306/employees_db/employees.sql

2.4 检查安装的数据库

root@localhost [employees] 16:39:42>show tables;
+---------------------+
| Tables_in_employees |
+---------------------+
| departments |
| dept_emp |
| dept_manager |
| employees |
| salaries |
| titles |
+---------------------+
6 rows in set (0.00 sec)