Docker (15): Start a standalone version of TIDB in Docker mode

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

1, about TIDB

Tidb is inspired by Google's F1 and Google Spanner, TIDB support features that include traditional RDBMS and NoSQL.
SQL fully supports MySQL, while others are also a distributed database.
What Sub-Library sub-table are weak, this direct division, super convenient. And it's open-source.
Is the domestic technology of large Bezoar Dongxu company Pincap developed.
It was the man who wrote Codis before.
Https://github.com/pingcap/tidb
Very powerful person, design a very good project.

2,TIDB Installation & Startup

docker pull pingcap/tidb#45.58 MBmkdir -p /data/tidb/datadocker--name tidb-server -d -v /data/tidb/data:/tmp/tidb -p 4000:4000 -p 10080:10080 pingcap/tidb:latest#设置数据文件,默认使用 goleveldb 存储。

Start a successful default port 4000, or you can disguise it as MySQL and change the port to 3306.

# mysql-h 127.0.0.1-p 4000-u root-d test--prompt= "tidb>"Welcome to  theMariaDB Monitor. Commands End  with; or \g.Your MySQL Connection ID is3Serverversion:5.7. 1-tidb-1.0MySQL Community Server (GPL) Copyright (c) -, ., Oracle, MariaDB Corporation Ab andOthers. Type' help; ' or ' \h '  forHelp. Type' \c '  to Clear  theCurrent input statement.tidb>

Log on successfully, server version:5.7.1-tidb-1.0 MySQL Community Server (GPL) tidb.
You can use port 10080 to view status information:

# curl localhost:10080/status{"connections":1,"version":"5.7.1-TiDB-1.0","git_hash":"31bc1083fc9195181d187639efb847d19037d9de"}

It should be used when the cluster is in the sense.

3, CREATE DATABASE & user

Create a database demo and create a user demo assignment permission.
Note: These SQL statements are key executed in MySQL & TIDB and successfully assigned permissions & login succeeded.

CREATE DATABASE demo CHARACTER SET utf8 COLLATE utf8_general_ci;CREATE USER 'demo'@'%' IDENTIFIED BY 'demo';GRANT ALL PRIVILEGES ON demo.* TO 'demo'@'%';FLUSH PRIVILEGES;

Using Golang for database insertion & querying data:

Package Mainimport ("FMT"_"Github.com/go-sql-driver/mysql"    "Database/sql"    "Time"    "StrConv"Func main () {db, err: = SQL. Open ("MySQL","Demo:demo@tcp (127.0.0.1:4000)/demo") FMT. PRINTLN (db, Err) //Start: = Time. Now () Loop: =10000     forI: =0; I < loop; i + + {result, err: = db. Exec (INSERT into users (' name ', age) VALUES (?,?) ","User"+strconv. Itoa (i), I,)ifi% (loop/Ten) ==0{FMT. Println (result, err)}} End : = time.  Now ()Fmt. Println ("Test Insert time:", End. Sub (start). Seconds ())}

4, summary

The text of this text connection is: http://blog.csdn.net/freewebsys/article/details/70843679 not allowed to reprint without the Bo master.
Bo main address is: Http://blog.csdn.net/freewebsys

Tidb is a very good alternative to MARIDB products.
Can be fully compatible with SQL query Ah, insert Ah, join AH.
Supports TB-level data storage at the same time. The speed of the machine is much faster.
And mariadb still old thinking, do not support the distribution of not ripe.
Tidb is also very convenient to expand. The key is that the code does not have to be modified, all of them to a maintenance.
When you're done, you can go home and wash your bed early.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.