Get the code, build, and run
git: The TiDB source code is hosted on GitHub as a git repository. To work with the git repository, please install
go: TiDB is a Go project. Therefore, you need a working Go environment to build it. See the previous Install Golang section to prepare the environment.
gcccommand is required to use
cgowhile building. To install
gcc, search for appropriate install guide for your OS.
mysqlclient (optional): After building TiDB from source, you can use the official MySQL client to connect to TiDB. It is not required if you want to build TiDB only.
TiDB could compile and run on Windows 10. However, it is not expected to be deployed on Windows, where you might encounter many compatibility problems. To have a better experience, we recommend you install WSL2 first.
Clone the source code to your development machine:
git clone https://github.com/pingcap/tidb.git
Build TiDB from the source code:
cd tidb make
Now that you have the
tidb-server binary under the
bin directory, execute it for a TiDB server instance:
This starts the TiDB server listening on port 4000 with embedded
You can use the official MySQL client to connect to TiDB:
mysql -h 127.0.0.1 -P 4000 -u root -D test --prompt="tidb> " --comments
-h 127.0.0.1sets the Host to local host loopback interface
-P 4000uses port 4000
-u rootconnects as root user (
-pnot given; the development build has no password for root.)
-D testuses the Schema/Database test
--prompt "tidb> "sets the prompt to distinguish it from a connection to MySQL
--commentspreserves comments like
/*T![clustered_index NONCLUSTERED */instead of stripping them when sending the query to the server.
If you encounter any problems during your journey, do not hesitate to reach out on the TiDB Internals forum.