From b4fe6062a75891eb49d995f217efd6968b573385 Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 24 Jun 2022 00:01:41 +0800 Subject: [PATCH] Update index.py --- plugins/mysql/index.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 873b435d9..2f886e58c 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -403,19 +403,22 @@ def my8cmd(version, method): # mysql 8.0 and 5.7 init_file = initDreplace(version) isInited = 0 - if version == '5.7': - isInited = initMysql57Data() - elif version == '8.0': - isInited = initMysql8Data() - if not isInited: - mw.execShell('systemctl start mysql') - initMysql8Pwd() - mw.execShell('systemctl stop mysql') + try: + if version == '5.7': + isInited = initMysql57Data() + elif version == '8.0': + isInited = initMysql8Data() - mw.execShell('systemctl ' + method + ' mysql') + if not isInited: + mw.execShell('systemctl start mysql') + initMysql8Pwd() + mw.execShell('systemctl stop mysql') - return 'ok' + mw.execShell('systemctl ' + method + ' mysql') + return 'ok' + except Exception as e: + return str(e) def appCMD(version, action):