默认情况 OceanBase 没有创建示例数据库 TPCC,需要手动创建。示例数据库必须在业务租户下创建。有关示例数据库介绍请参考 关于示例数据库 TPCC

租户创建好后,需要创建相应的 DataBase 来存放示例数据库的对象,还要分配相应的用户和访问权限。

示例

  1. 通过 obclient 连接 MySQL 租户。
  1. #obclient -h192.168.1.101 -uroot@obmysql#obdemo -P2883 -pabcABC123 -A oceanbase
  2. obclient: [Warning] Using a password on the command line interface can be insecure.
  3. Welcome to the OceanBase monitor. Commands end with ; or \g.
  4. Your OceanBase connection id is 57981
  5. Server version: 5.6.25 OceanBase 2.2.20 (…) (Built Aug 10 2019 15:27:33)
  6. <…省略…>
  7. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  1. 创建一个数据库。
  1. obclient> create database tpccdb;
  2. Query OK, 1 row affected (0.02 sec)
  3. obclient> show databases;
  4. +--------------------+
  5. | Database |
  6. +--------------------+
  7. | oceanbase |
  8. | information_schema |
  9. | mysql |
  10. | test |
  11. | tpccdb |
  12. +--------------------+
  13. 5 rows in set (0.01 sec)
  1. 创建一个用户并赋权。
  1. obclient> grant all privileges on tpccdb.* to tpcc identified by '123456';
  2. Query OK, 0 rows affected (0.02 sec)
  3. obclient> show grants for tpcc;
  4. +----------------------------------------------+
  5. | Grants for tpcc@% |
  6. +----------------------------------------------+
  7. | GRANT USAGE ON *.* TO 'tpcc' |
  8. | GRANT SELECT ON `oceanbase`.* TO 'tpcc' |
  9. | GRANT ALL PRIVILEGES ON `tpccdb`.* TO 'tpcc' |
  10. +----------------------------------------------+
  11. 3 rows in set (0.01 sec)
  12. obclient>
  1. 创建数据库对象
  1. obclient> use tpccdb;
  2. Database changed
  3. obclient> source create_mysql_tables.sql
  4. Query OK, 0 rows affected (0.01 sec)
  5. <…省略…>
  6. Query OK, 0 rows affected (0.01 sec)
  7. +------------------+
  8. | Tables_in_tpccdb |
  9. +------------------+
  10. | cust |
  11. | dist |
  12. | hist |
  13. | item |
  14. | load_hist |
  15. | load_proc |
  16. | nord |
  17. | ordl |
  18. | ordr |
  19. | stock_item |
  20. | stok |
  21. | ware |
  22. +------------------+
  23. 12 rows in set (0.00 sec)
  1. 初始化表数据。
  1. obclient> source init_data.sql
  2. Query OK, 0 rows affected (0.01 sec)
  3. <…省略…>
  4. Query OK, 0 rows affected (0.01 sec)
  5. +------------+----------+
  6. | table_name | rows_cnt |
  7. +------------+----------+
  8. | WARE | 2 |
  9. | DIST | 20 |
  10. | NORD | 40 |
  11. | ORDR | 60 |
  12. | HIST | 240 |
  13. | ITEM | 622 |
  14. | ORDL | 626 |
  15. | CUST | 1040 |
  16. | STOK | 1244 |
  17. +------------+----------+
  18. 9 rows in set (0.01 sec)