-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update tidb secret docs and charts (#398)
* update tidb secret docs and charts * update operation-guide.md * add _initialize_tidb_users.py.tpl
- Loading branch information
Showing
5 changed files
with
35 additions
and
27 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
charts/tidb-cluster/templates/scripts/_initialize_tidb_users.py.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import os, MySQLdb | ||
host = '{{ template "cluster.name" . }}-tidb' | ||
port = 4000 | ||
password_dir = '/etc/tidb/password' | ||
conn = MySQLdb.connect(host=host, port=port, user='root', connect_timeout=5) | ||
for file in os.listdir(password_dir): | ||
if file.startswith('.'): | ||
continue | ||
user = file | ||
with open(os.path.join(password_dir, file), 'r') as f: | ||
password = f.read() | ||
if user == 'root': | ||
conn.cursor().execute("set password for 'root'@'%%' = %s;", (password,)) | ||
else: | ||
conn.cursor().execute("create user %s@'%%' identified by %s;", (user, password,)) | ||
conn.cursor().execute("flush privileges;") | ||
conn.commit() | ||
{{- if .Values.tidb.initSql }} | ||
with open('/data/init.sql', 'r') as sql: | ||
for line in sql.readlines(): | ||
conn.cursor().execute(line) | ||
conn.commit() | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters