安装mysql Employees 演示数据库

安装教程

官方教程 Employees Sample Database
网友教程 mysql 安装employees db的步骤

错误总结

  1. 导入employees.sql出错(导入*.dump文件出错),错误如下
D:\mysql\bin>mysql  -t -u root -p < D:\practice\sql\mysql\employee_sample\employees_db\employees.sql
Enter password: ******
+-----------------------------+
| INFO                        |
+-----------------------------+
| CREATING DATABASE STRUCTURE |
+-----------------------------+
+---------------------+
| INFO                |
+---------------------+
| LOADING departments |
+---------------------+
ERROR at line 108: Failed to open file 'load_departments.dump', error: 2

解决MySQL导入employees数据库出错问题

修改employees.sql文件

  • set storage_engine = InnoDB; 改为 set default_storage_engine = InnoDB;
  • select CONCAT('storage engine: ', @@storage_engine) as INFO; 改为 select CONCAT('storage engine: ', @@default_storage_engine) as INFO;
  • 所有*.dump文件为绝对路径,比如 source D:/practice/sql/mysql/employee_sample/employees_db/load_departments.dump; 改为 source D:/practice/sql/mysql/employee_sample/employees_db/load_departments.dump;

然后重新运行成功了,如下

D:\mysql\bin>mysql  -t -u root -p < D:\practice\sql\mysql\employee_sample\employees_db\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 |
+------------------+
  1. md5和sha方式验证下载的数据库完整性出错,错误如下
D:\mysql\bin>mysql  -t -u root -p < D:\practice\sql\mysql\employee_sample\employees_db\test_employees_sha.sql
Enter password: ******
+----------------------+
| INFO                 |
+----------------------+
| TESTING INSTALLATION |
+----------------------+
ERROR 1193 (HY000) at line 28: Unknown system variable 'storage_engine'

解决方法,将test_employees_sha.sql和test_employees_md5.sql文件中 SET storage_engine=MyISAM; 改为 set default_storage_engine = InnoDB;

修改完后,再次运行显示成功,如下:

D:\mysql\bin>mysql  -t -u root -p < D:\practice\sql\mysql\employee_sample\employees_db\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        |
+--------------+---------------+-----------+
D:\mysql\bin>mysql  -t -u root -p < D:\practice\sql\mysql\employee_sample\employees_db\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        |
+--------------+---------------+-----------+

到此就算安装完毕了,我们可以愉快得和这个演示库玩耍了。

最后附一张演示库的结构图:
安装mysql Employees 演示数据库

上一篇:mysql之分组函数10


下一篇:MySQL