1. 程式人生 > >MySQL 8.0.12 安裝部署官方示例資料庫

MySQL 8.0.12 安裝部署官方示例資料庫

下載MySQL官方提供的資料庫:
wget http://downloads.mysql.com/docs/world.sql.zip
wget http://downloads.mysql.com/docs/world_x-db.zip
wget http://downloads.mysql.com/docs/sakila-db.zip
wget https://launchpad.net/test-db/employees-db-1/1.0.6/+download/employees_db-full-1.0.6.tar.bz2

部署:
# unzip world.sql.zip 
# unzip world_x-db.zip
# unzip sakila-db.zip
# tar -xjvf employees_db-full-1.0.6.tar.bz2

--本地匯入資料:
# mysql -p -S /tmp/mysql8001.sock  <world.sql
# mysql -p -S /tmp/mysql8001.sock  <world_x-db/world_x.sql 

# mysql -p -S /tmp/mysql8001.sock  <sakila-db/sakila-schema.sql
# mysql -p -S /tmp/mysql8001.sock  <sakila-db/sakila-data.sql 

# # cd employees_db

# mysql -p -S /tmp/mysql8001.sock  < employees.sql 
Enter password: 
INFO
CREATING DATABASE STRUCTURE
INFO
LOADING departments
INFO
LOADING employees
INFO
LOADING dept_emp
INFO
LOADING dept_manager
INFO
LOADING titles
INFO
LOADING salaries


--employees SHA驗證:
time mysql -p -S /tmp/mysql8001.sock  < test_employees_sha.sql 
+----------------------+
| INFO                 |
+----------------------+
| TESTING INSTALLATION |
+----------------------+
+--------------+------------------+------------------------------------------+
| table_name   | expected_records | expected_crc                             |
+--------------+------------------+------------------------------------------+
| employees    |           300024 | 4d4aa689914d8fd41db7e45c2168e7dcb9697359 |
| departments  |                9 | 4b315afa0e35ca6649df897b958345bcb3d2b764 |
| dept_manager |               24 | 9687a7d6f93ca8847388a42a6d8d93982a841c6c |
| dept_emp     |           331603 | f16f6ce609d032d6b1b34748421e9195c5083da8 |
| 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 | f16f6ce609d032d6b1b34748421e9195c5083da8 |
| 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        |
+--------------+---------------+-----------+
--employees MD5 驗證:
+----------------------+
| INFO                 |
+----------------------+
| TESTING INSTALLATION |
+----------------------+
+--------------+------------------+----------------------------------+
| table_name   | expected_records | expected_crc                     |
+--------------+------------------+----------------------------------+
| employees    |           300024 | 4ec56ab5ba37218d187cf6ab09ce1aa1 |
| departments  |                9 | d1af5e170d2d1591d776d5638d71fc5f |
| dept_manager |               24 | 8720e2f0853ac9096b689c14664f847e |
| dept_emp     |           331603 | c2c4fc7f0506e50959a6c67ad55cac31 |
| 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 | c2c4fc7f0506e50959a6c67ad55cac31 |
| 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        |
+--------------+---------------+-----------+
在GroupReplication環境下指令碼需要test_employees_sha.sql  和test_employees_md5.sql 需要修改。 
註釋 上述示例資料庫在單例項資料庫上驗證沒問題,若是在Group Replication環境下需要修改一些引數:
1.Group Replication只支援InnoDB儲存引擎
否則報錯:
ERROR 3098 (HY000): The table does not comply with the requirements by an external plugin.

2.每個表需要有主鍵
否則報錯:
ERROR 3098 (HY000) at line 61: The table does not comply with the requirements by an external plugin.
在GroupReplication下可能的報錯資訊:
ERROR 3100 (HY000): Error on observer while running replication hook 'before_commit'.

登入資料庫檢視資料:
mysql> show databases;
+-------------------------------+
| Database                      |
+-------------------------------+
| employees                     |
| information_schema            |
| mysql                         |
| mysql_innodb_cluster_metadata |
| performance_schema            |
| sakila                        |
| sys                           |
| world                         |
| world_x                       |
+-------------------------------+
10 rows in set (0.01 sec)