Skip to content

Instantly share code, notes, and snippets.

@jniltinho
Last active January 23, 2018 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jniltinho/6e2342efdaadf285aa489143a3edb7e8 to your computer and use it in GitHub Desktop.
Save jniltinho/6e2342efdaadf285aa489143a3edb7e8 to your computer and use it in GitHub Desktop.
Install TiDB on ISPConfig as MariaDB
#!/bin/bash
## Install and Setup TiDB on Linux
## https://github.com/pingcap/tidb
## https://github.com/pingcap/docs/blob/master/sql/privilege.md
## https://pingcap.com/blog/2016-10-17-how-we-build-tidb/
## https://github.com/pingcap/tidb/blob/master/config/config.toml.example
## Remove MariaDB/Mysql
systemctl stop mysql mysqld
systemctl disable mysql mysqld
killall mysqld
rm -rf /var/run/mysqld
useradd tidb -d /var/lib/tidb -m
usermod -a -G tidb tidb
## mkdir -p /var/run/mysqld
## chown -R tidb:tidb /var/run/mysqld
## For --socket /var/run/mysqld/mysqld.sock
cd /var/lib/tidb
wget http://download.pingcap.org/tidb-latest-linux-amd64.tar.gz
tar -xzf tidb-latest-linux-amd64.tar.gz
mv tidb-latest-linux-amd64/bin .
rm -rf tidb-latest-linux-amd64.tar.gz tidb-latest-linux-amd64
mkdir -p /var/lib/tidb/log/
mkdir -p /var/lib/tidb/storage/
chown -R tidb:tidb *
## For ISPConfig ##
### Create Service in SystemD
echo '[Unit]
Description=TiDB Daemon
After=syslog.target network.target
[Service]
WorkingDirectory=/var/lib/tidb
ExecStart=/var/lib/tidb/bin/tidb-server -P 3306 -path /var/lib/tidb/storage --log-file=/var/lib/tidb/log/tidb.log
SyslogIdentifier=tidb
User=tidb
Group=tidb
[Install]
WantedBy=multi-user.target' > /etc/systemd/system/tidb.service
systemctl daemon-reload
systemctl start tidb
systemctl enable tidb
echo "set password for 'root'@'%' = 'tidbrootpass';
SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION';
SET SESSION sql_mode = 'NO_ENGINE_SUBSTITUTION';
flush privileges;" > set_root_pass.sql
mysql -h 127.0.0.1 -P 4000 < set_root_pass.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment