Employees 数据库是一个用于学习和测试的数据库,大约160MB,4百万条记录。
官方安装文档:https://dev.mysql.com/doc/employee/en/employees-installation.html
根据官方文档的连接,我们可以找到下载该数据库的两种方式:
- employees_db-full-1.0.6.tar.bz2
- github-test_db 使用 git clone 进行仓库拉取
解压和拉取
[root@MyServer Downloads]> tar jxf employees_db-full-1.0.6.tar.bz2
# 老师讲解时说是解压有问题,但是我这里却可以解压
[root@MyServer Downloads]> cd employees_db
[root@MyServer employees_db]> ll
total 164492
-rw-r--r--. 1 501 games 752 Mar 30 2009 Changelog
-rw-r--r--. 1 501 games 6460 Oct 9 2008 employees_partitioned2.sql
-rw-r--r--. 1 501 games 7624 Feb 6 2009 employees_partitioned3.sql
-rw-r--r--. 1 501 games 5660 Feb 6 2009 employees_partitioned.sql
-rw-r--r--. 1 501 games 3861 Nov 28 2008 employees.sql # 主要文件
-rw-r--r--. 1 501 games 241 Jul 30 2008 load_departments.dump
-rw-r--r--. 1 501 games 13828291 Mar 30 2009 load_dept_emp.dump
-rw-r--r--. 1 501 games 1043 Jul 30 2008 load_dept_manager.dump
-rw-r--r--. 1 501 games 17422825 Jul 30 2008 load_employees.dump
-rw-r--r--. 1 501 games 115848997 Jul 30 2008 load_salaries.dump
-rw-r--r--. 1 501 games 21265449 Jul 30 2008 load_titles.dump
-rw-r--r--. 1 501 games 3889 Mar 30 2009 objects.sql
-rw-r--r--. 1 501 games 2211 Jul 30 2008 README
-rw-r--r--. 1 501 games 4455 Mar 30 2009 test_employees_md5.sql
-rw-r--r--. 1 501 games 4450 Mar 30 2009 test_employees_sha.sql
[root@MyServer github_employees]> git clone https://github.com/datacharmer/test_db.git
Initialized empty Git repository in /root/Downloads/github_employees/test_db/.git/
Cloning into 'test_db'...
remote: Counting objects: 94, done.
remote: Total 94 (delta 0), reused 0 (delta 0), pack-reused 94
Unpacking objects: 100% (94/94), done.
Checking connectivity... done.
[root@MyServer test_db]> ll
total 168340
-rw-r--r--. 1 root root 964 Dec 2 21:25 Changelog
-rw-r--r--. 1 root root 7948 Dec 2 21:25 employees_partitioned_5.1.sql
-rw-r--r--. 1 root root 6276 Dec 2 21:25 employees_partitioned.sql
-rw-r--r--. 1 root root 4193 Dec 2 21:25 employees.sql # 主要文件
drwxrwxr-x. 2 root root 4096 Dec 2 21:25 images
-rw-r--r--. 1 root root 250 Dec 2 21:25 load_departments.dump
-rw-r--r--. 1 root root 14159880 Dec 2 21:25 load_dept_emp.dump
-rw-r--r--. 1 root root 1090 Dec 2 21:25 load_dept_manager.dump
-rw-r--r--. 1 root root 17722832 Dec 2 21:25 load_employees.dump
-rw-r--r--. 1 root root 39806034 Dec 2 21:25 load_salaries1.dump
-rw-r--r--. 1 root root 39805981 Dec 2 21:25 load_salaries2.dump
-rw-r--r--. 1 root root 39080916 Dec 2 21:25 load_salaries3.dump
-rw-r--r--. 1 root root 21708736 Dec 2 21:25 load_titles.dump
-rw-r--r--. 1 root root 4568 Dec 2 21:25 objects.sql
-rw-r--r--. 1 root root 4007 Dec 2 21:25 README.md
drwxrwxr-x. 2 root root 4096 Dec 2 21:25 sakila
-rw-r--r--. 1 root root 272 Dec 2 21:25 show_elapsed.sql
-rwxr-xr-x. 1 root root 1800 Dec 2 21:25 sql_test.sh
-rw-r--r--. 1 root root 4878 Dec 2 21:25 test_employees_md5.sql
-rw-r--r--. 1 root root 4882 Dec 2 21:25 test_employees_sha.sql
解压出来的主要文件大小是不一样的,且根据网页上发布和更新的时间上看,github 中的时间比较新,所以这里使用 github 中源作为的安装文件。
安装
[root@MyServer test_db]> mysql -uroot -S /tmp/mysql.sock_57 -p < employees.sql
Enter password:
INFO
CREATING DATABASE STRUCTURE
INFO
storage engine: InnoDB
INFO
LOADING departments
INFO
LOADING employees
INFO
LOADING dept_emp
INFO
LOADING dept_manager
INFO
LOADING titles
INFO
LOADING salaries
data_load_time_diff
00:01:51
验证
[root@MyServer test_db]> time mysql -uroot -S /tmp/mysql.sock_57 -p -t < test_employees_sha.sql
Enter password:
+----------------------+
| INFO |
+----------------------+
| TESTING INSTALLATION |
+----------------------+
+--------------+------------------+------------------------------------------+
| table_name | expected_records | expected_crc |
+--------------+------------------+------------------------------------------+
| employees | 300024 | 4d4aa689914d8fd41db7e45c2168e7dcb9697359 |
| departments | 9 | 4b315afa0e35ca6649df897b958345bcb3d2b764 |
| dept_manager | 24 | 9687a7d6f93ca8847388a42a6d8d93982a841c6c |
| dept_emp | 331603 | d95ab9fe07df0865f592574b3b33b9c741d9fd1b |
| titles | 443308 | d12d5f746b88f07e69b9e36675b6067abb01b60e |
| salaries | 2844047 | b5a1785c27d75e33a4173aaa22ccf41ebd7d4a9f |
+--------------+------------------+------------------------------------------+
+--------------+------------------+------------------------------------------+
| table_name | found_records | found_crc |
+--------------+------------------+------------------------------------------+
| employees | 300024 | 4d4aa689914d8fd41db7e45c2168e7dcb9697359 |
| departments | 9 | 4b315afa0e35ca6649df897b958345bcb3d2b764 |
| dept_manager | 24 | 9687a7d6f93ca8847388a42a6d8d93982a841c6c |
| dept_emp | 331603 | d95ab9fe07df0865f592574b3b33b9c741d9fd1b |
| titles | 443308 | d12d5f746b88f07e69b9e36675b6067abb01b60e |
| salaries | 2844047 | b5a1785c27d75e33a4173aaa22ccf41ebd7d4a9f |
+--------------+------------------+------------------------------------------+
+--------------+---------------+-----------+
| table_name | records_match | crc_match |
+--------------+---------------+-----------+
| employees | OK | ok |
| departments | OK | ok |
| dept_manager | OK | ok |
| dept_emp | OK | ok |
| titles | OK | ok |
| salaries | OK | ok |
+--------------+---------------+-----------+
+------------------+
| computation_time |
+------------------+
| 00:00:18 |
+------------------+
+---------+--------+
| summary | result |
+---------+--------+
| CRC | OK |
| count | OK |
+---------+--------+
real 0m19.406s
user 0m0.005s
sys 0m0.004s
[root@MyServer test_db]> time mysql -uroot -S /tmp/mysql.sock_57 -p -t < test_employees_md5.sql
Enter password:
+----------------------+
| INFO |
+----------------------+
| TESTING INSTALLATION |
+----------------------+
+--------------+------------------+----------------------------------+
| table_name | expected_records | expected_crc |
+--------------+------------------+----------------------------------+
| employees | 300024 | 4ec56ab5ba37218d187cf6ab09ce1aa1 |
| departments | 9 | d1af5e170d2d1591d776d5638d71fc5f |
| dept_manager | 24 | 8720e2f0853ac9096b689c14664f847e |
| dept_emp | 331603 | ccf6fe516f990bdaa49713fc478701b7 |
| titles | 443308 | bfa016c472df68e70a03facafa1bc0a8 |
| salaries | 2844047 | fd220654e95aea1b169624ffe3fca934 |
+--------------+------------------+----------------------------------+
+--------------+------------------+----------------------------------+
| table_name | found_records | found_crc |
+--------------+------------------+----------------------------------+
| employees | 300024 | 4ec56ab5ba37218d187cf6ab09ce1aa1 |
| departments | 9 | d1af5e170d2d1591d776d5638d71fc5f |
| dept_manager | 24 | 8720e2f0853ac9096b689c14664f847e |
| dept_emp | 331603 | ccf6fe516f990bdaa49713fc478701b7 |
| titles | 443308 | bfa016c472df68e70a03facafa1bc0a8 |
| salaries | 2844047 | fd220654e95aea1b169624ffe3fca934 |
+--------------+------------------+----------------------------------+
+--------------+---------------+-----------+
| table_name | records_match | crc_match |
+--------------+---------------+-----------+
| employees | OK | ok |
| departments | OK | ok |
| dept_manager | OK | ok |
| dept_emp | OK | ok |
| titles | OK | ok |
| salaries | OK | ok |
+--------------+---------------+-----------+
+------------------+
| computation_time |
+------------------+
| 00:00:16 |
+------------------+
+---------+--------+
| summary | result |
+---------+--------+
| CRC | OK |
| count | OK |
+---------+--------+
real 0m18.452s
user 0m0.007s
sys 0m0.005s
至此,Employees 测试数据库就安装完成了。
作者:殷建卫 链接:https://www.yuque.com/yinjianwei/vyrvkf/tn8cpc 来源:殷建卫 - 架构笔记 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。