Employees 数据库是一个用于学习和测试的数据库,大约160MB,4百万条记录。

官方安装文档:https://dev.mysql.com/doc/employee/en/employees-installation.html

根据官方文档的连接,我们可以找到下载该数据库的两种方式:

解压和拉取

  1. [root@MyServer Downloads]> tar jxf employees_db-full-1.0.6.tar.bz2
  2. # 老师讲解时说是解压有问题,但是我这里却可以解压
  3. [root@MyServer Downloads]> cd employees_db
  4. [root@MyServer employees_db]> ll
  5. total 164492
  6. -rw-r--r--. 1 501 games 752 Mar 30 2009 Changelog
  7. -rw-r--r--. 1 501 games 6460 Oct 9 2008 employees_partitioned2.sql
  8. -rw-r--r--. 1 501 games 7624 Feb 6 2009 employees_partitioned3.sql
  9. -rw-r--r--. 1 501 games 5660 Feb 6 2009 employees_partitioned.sql
  10. -rw-r--r--. 1 501 games 3861 Nov 28 2008 employees.sql # 主要文件
  11. -rw-r--r--. 1 501 games 241 Jul 30 2008 load_departments.dump
  12. -rw-r--r--. 1 501 games 13828291 Mar 30 2009 load_dept_emp.dump
  13. -rw-r--r--. 1 501 games 1043 Jul 30 2008 load_dept_manager.dump
  14. -rw-r--r--. 1 501 games 17422825 Jul 30 2008 load_employees.dump
  15. -rw-r--r--. 1 501 games 115848997 Jul 30 2008 load_salaries.dump
  16. -rw-r--r--. 1 501 games 21265449 Jul 30 2008 load_titles.dump
  17. -rw-r--r--. 1 501 games 3889 Mar 30 2009 objects.sql
  18. -rw-r--r--. 1 501 games 2211 Jul 30 2008 README
  19. -rw-r--r--. 1 501 games 4455 Mar 30 2009 test_employees_md5.sql
  20. -rw-r--r--. 1 501 games 4450 Mar 30 2009 test_employees_sha.sql
  21. [root@MyServer github_employees]> git clone https://github.com/datacharmer/test_db.git
  22. Initialized empty Git repository in /root/Downloads/github_employees/test_db/.git/
  23. Cloning into 'test_db'...
  24. remote: Counting objects: 94, done.
  25. remote: Total 94 (delta 0), reused 0 (delta 0), pack-reused 94
  26. Unpacking objects: 100% (94/94), done.
  27. Checking connectivity... done.
  28. [root@MyServer test_db]> ll
  29. total 168340
  30. -rw-r--r--. 1 root root 964 Dec 2 21:25 Changelog
  31. -rw-r--r--. 1 root root 7948 Dec 2 21:25 employees_partitioned_5.1.sql
  32. -rw-r--r--. 1 root root 6276 Dec 2 21:25 employees_partitioned.sql
  33. -rw-r--r--. 1 root root 4193 Dec 2 21:25 employees.sql # 主要文件
  34. drwxrwxr-x. 2 root root 4096 Dec 2 21:25 images
  35. -rw-r--r--. 1 root root 250 Dec 2 21:25 load_departments.dump
  36. -rw-r--r--. 1 root root 14159880 Dec 2 21:25 load_dept_emp.dump
  37. -rw-r--r--. 1 root root 1090 Dec 2 21:25 load_dept_manager.dump
  38. -rw-r--r--. 1 root root 17722832 Dec 2 21:25 load_employees.dump
  39. -rw-r--r--. 1 root root 39806034 Dec 2 21:25 load_salaries1.dump
  40. -rw-r--r--. 1 root root 39805981 Dec 2 21:25 load_salaries2.dump
  41. -rw-r--r--. 1 root root 39080916 Dec 2 21:25 load_salaries3.dump
  42. -rw-r--r--. 1 root root 21708736 Dec 2 21:25 load_titles.dump
  43. -rw-r--r--. 1 root root 4568 Dec 2 21:25 objects.sql
  44. -rw-r--r--. 1 root root 4007 Dec 2 21:25 README.md
  45. drwxrwxr-x. 2 root root 4096 Dec 2 21:25 sakila
  46. -rw-r--r--. 1 root root 272 Dec 2 21:25 show_elapsed.sql
  47. -rwxr-xr-x. 1 root root 1800 Dec 2 21:25 sql_test.sh
  48. -rw-r--r--. 1 root root 4878 Dec 2 21:25 test_employees_md5.sql
  49. -rw-r--r--. 1 root root 4882 Dec 2 21:25 test_employees_sha.sql

解压出来的主要文件大小是不一样的,且根据网页上发布和更新的时间上看,github 中的时间比较新,所以这里使用 github 中源作为的安装文件。

安装

  1. [root@MyServer test_db]> mysql -uroot -S /tmp/mysql.sock_57 -p < employees.sql
  2. Enter password:
  3. INFO
  4. CREATING DATABASE STRUCTURE
  5. INFO
  6. storage engine: InnoDB
  7. INFO
  8. LOADING departments
  9. INFO
  10. LOADING employees
  11. INFO
  12. LOADING dept_emp
  13. INFO
  14. LOADING dept_manager
  15. INFO
  16. LOADING titles
  17. INFO
  18. LOADING salaries
  19. data_load_time_diff
  20. 00:01:51

验证

  1. [root@MyServer test_db]> time mysql -uroot -S /tmp/mysql.sock_57 -p -t < test_employees_sha.sql
  2. Enter password:
  3. +----------------------+
  4. | INFO |
  5. +----------------------+
  6. | TESTING INSTALLATION |
  7. +----------------------+
  8. +--------------+------------------+------------------------------------------+
  9. | table_name | expected_records | expected_crc |
  10. +--------------+------------------+------------------------------------------+
  11. | employees | 300024 | 4d4aa689914d8fd41db7e45c2168e7dcb9697359 |
  12. | departments | 9 | 4b315afa0e35ca6649df897b958345bcb3d2b764 |
  13. | dept_manager | 24 | 9687a7d6f93ca8847388a42a6d8d93982a841c6c |
  14. | dept_emp | 331603 | d95ab9fe07df0865f592574b3b33b9c741d9fd1b |
  15. | titles | 443308 | d12d5f746b88f07e69b9e36675b6067abb01b60e |
  16. | salaries | 2844047 | b5a1785c27d75e33a4173aaa22ccf41ebd7d4a9f |
  17. +--------------+------------------+------------------------------------------+
  18. +--------------+------------------+------------------------------------------+
  19. | table_name | found_records | found_crc |
  20. +--------------+------------------+------------------------------------------+
  21. | employees | 300024 | 4d4aa689914d8fd41db7e45c2168e7dcb9697359 |
  22. | departments | 9 | 4b315afa0e35ca6649df897b958345bcb3d2b764 |
  23. | dept_manager | 24 | 9687a7d6f93ca8847388a42a6d8d93982a841c6c |
  24. | dept_emp | 331603 | d95ab9fe07df0865f592574b3b33b9c741d9fd1b |
  25. | titles | 443308 | d12d5f746b88f07e69b9e36675b6067abb01b60e |
  26. | salaries | 2844047 | b5a1785c27d75e33a4173aaa22ccf41ebd7d4a9f |
  27. +--------------+------------------+------------------------------------------+
  28. +--------------+---------------+-----------+
  29. | table_name | records_match | crc_match |
  30. +--------------+---------------+-----------+
  31. | employees | OK | ok |
  32. | departments | OK | ok |
  33. | dept_manager | OK | ok |
  34. | dept_emp | OK | ok |
  35. | titles | OK | ok |
  36. | salaries | OK | ok |
  37. +--------------+---------------+-----------+
  38. +------------------+
  39. | computation_time |
  40. +------------------+
  41. | 00:00:18 |
  42. +------------------+
  43. +---------+--------+
  44. | summary | result |
  45. +---------+--------+
  46. | CRC | OK |
  47. | count | OK |
  48. +---------+--------+
  49. real 0m19.406s
  50. user 0m0.005s
  51. sys 0m0.004s
  52. [root@MyServer test_db]> time mysql -uroot -S /tmp/mysql.sock_57 -p -t < test_employees_md5.sql
  53. Enter password:
  54. +----------------------+
  55. | INFO |
  56. +----------------------+
  57. | TESTING INSTALLATION |
  58. +----------------------+
  59. +--------------+------------------+----------------------------------+
  60. | table_name | expected_records | expected_crc |
  61. +--------------+------------------+----------------------------------+
  62. | employees | 300024 | 4ec56ab5ba37218d187cf6ab09ce1aa1 |
  63. | departments | 9 | d1af5e170d2d1591d776d5638d71fc5f |
  64. | dept_manager | 24 | 8720e2f0853ac9096b689c14664f847e |
  65. | dept_emp | 331603 | ccf6fe516f990bdaa49713fc478701b7 |
  66. | titles | 443308 | bfa016c472df68e70a03facafa1bc0a8 |
  67. | salaries | 2844047 | fd220654e95aea1b169624ffe3fca934 |
  68. +--------------+------------------+----------------------------------+
  69. +--------------+------------------+----------------------------------+
  70. | table_name | found_records | found_crc |
  71. +--------------+------------------+----------------------------------+
  72. | employees | 300024 | 4ec56ab5ba37218d187cf6ab09ce1aa1 |
  73. | departments | 9 | d1af5e170d2d1591d776d5638d71fc5f |
  74. | dept_manager | 24 | 8720e2f0853ac9096b689c14664f847e |
  75. | dept_emp | 331603 | ccf6fe516f990bdaa49713fc478701b7 |
  76. | titles | 443308 | bfa016c472df68e70a03facafa1bc0a8 |
  77. | salaries | 2844047 | fd220654e95aea1b169624ffe3fca934 |
  78. +--------------+------------------+----------------------------------+
  79. +--------------+---------------+-----------+
  80. | table_name | records_match | crc_match |
  81. +--------------+---------------+-----------+
  82. | employees | OK | ok |
  83. | departments | OK | ok |
  84. | dept_manager | OK | ok |
  85. | dept_emp | OK | ok |
  86. | titles | OK | ok |
  87. | salaries | OK | ok |
  88. +--------------+---------------+-----------+
  89. +------------------+
  90. | computation_time |
  91. +------------------+
  92. | 00:00:16 |
  93. +------------------+
  94. +---------+--------+
  95. | summary | result |
  96. +---------+--------+
  97. | CRC | OK |
  98. | count | OK |
  99. +---------+--------+
  100. real 0m18.452s
  101. user 0m0.007s
  102. sys 0m0.005s

至此,Employees 测试数据库就安装完成了。

作者:殷建卫 链接:https://www.yuque.com/yinjianwei/vyrvkf/tn8cpc 来源:殷建卫 - 架构笔记 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。