From 4d83c44a73c0b56e5be4bc391bd4434d7a95dfd0 Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 25 Sep 2022 13:11:28 +0800 Subject: [PATCH] Update index.py --- plugins/mysql/index.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 84eb5f41a..be8c22062 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -426,6 +426,18 @@ def initMysqlPwd(): pwd + ' -e "drop database test";' mw.execShell(drop_test_db) + # 删除冗余账户 + hostname = mw.execShell('hostname')[0] + drop_hostname = "drop user ''@'" + hostname + "'" + + drop_hostname = serverdir + '/bin/mysql --defaults-file=' + \ + myconf + ' -uroot -p' + pwd + ' -e "drop user ''@' + hostname + '";' + mw.execShell(drop_hostname) + + drop_root_hostname = serverdir + '/bin/mysql --defaults-file=' + \ + myconf + ' -uroot -p' + pwd + ' -e "drop user \'root\'@' + hostname + '";' + mw.execShell(drop_root_hostname) + pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (pwd,)) return True