Rate This Document
Findability
Accuracy
Completeness
Readability

Running TiDB

  1. Copy the executable files to the specified directory. (This step is required only for installing TiDB from source code.)
    1
    2
    3
    cp /home/pd/bin/pd-server /data/bin
    cp /home/tikv/target/debug/tikv-server /data/bin
    cp /home/tidb/bin/tidb-server /data/bin
    
  2. Install the MySQL client.
    1
    yum -y install mysql
    

  3. Start the TiDB service.
    1
    2
    cd /data/bin
    ./pd-server --data-dir=pd --log-file=pd.log & ./tikv-server --pd='127.0.0.1:2379' --data-dir=tikv --log-file=tikv.log & ./tidb-server --store=tikv --path='127.0.0.1:2379' --log-file=tidb.log &
    

  4. Test the connection.

    Wait for about 1 minute and connect to the database. If the connection is successful, TiDB functions properly.

    1
    mysql -h 127.0.0.1 -u root -P 4000
    

  5. Check the TiDB version.
    1
    select tidb_version()\G
    

  6. Create a TiDB database.
    1
    2
    create database TiDB;
    use TiDB;
    

  7. Create a tab_tidb table.
    1
    2
    3
    4
    5
    6
    7
    CREATE TABLE `tab_tidb` ( \
    `id` int(11) NOT NULL AUTO_INCREMENT, \
    `name` varchar(20) NOT NULL DEFAULT '', \
    `age` int(11) NOT NULL DEFAULT 0, \
    `version` varchar(20) NOT NULL DEFAULT '', \
    PRIMARY KEY (`id`), \
    KEY `idx_age` (`age`));
    

  8. Insert data.
    1
    insert into `tab_tidb` values (1, 'TiDB', 5, 'TIDB-v3.0.13');
    
  9. View the result.
    1
    select * from tab_tidb;
    

  10. Delete data.
    1
    delete from `tab_tidb` where name='TiDB';
    
  11. View the result.
    1
    select * from tab_tidb;
    

  12. Check the TiKV Store status, store_id, storage status, and startup time.
    1
    select STORE_ID,ADDRESS,STORE_STATE,STORE_STATE_NAME,CAPACITY,AVAILABLE,UPTIME from INFORMATION_SCHEMA.TIKV_STORE_STATUS;
    

  13. Exit the database.
    1
    exit;