|
|
@ -284,6 +284,19 @@ def initMysqlData(): |
|
|
|
return 1 |
|
|
|
return 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def initMysql57Data(): |
|
|
|
|
|
|
|
datadir = getDataDir() |
|
|
|
|
|
|
|
if not os.path.exists(datadir + '/mysql'): |
|
|
|
|
|
|
|
serverdir = getServerDir() |
|
|
|
|
|
|
|
myconf = serverdir + "/etc/my.cnf" |
|
|
|
|
|
|
|
user = pGetDbUser() |
|
|
|
|
|
|
|
cmd = 'cd ' + serverdir + ' && ./bin/mysqld --defaults-file=' + myconf + \ |
|
|
|
|
|
|
|
' --initialize --explicit_defaults_for_timestamp' |
|
|
|
|
|
|
|
mw.execShell(cmd) |
|
|
|
|
|
|
|
return 0 |
|
|
|
|
|
|
|
return 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def initMysql8Data(): |
|
|
|
def initMysql8Data(): |
|
|
|
datadir = getDataDir() |
|
|
|
datadir = getDataDir() |
|
|
|
if not os.path.exists(datadir + '/mysql'): |
|
|
|
if not os.path.exists(datadir + '/mysql'): |
|
|
@ -348,7 +361,8 @@ def initMysql8Pwd(): |
|
|
|
if len(password) == 0: |
|
|
|
if len(password) == 0: |
|
|
|
return True |
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
#print('localhost', 3306, 'root', password, "/www/server/mysql/mysql.sock") |
|
|
|
# print('localhost', 3306, 'root', password, |
|
|
|
|
|
|
|
# "/www/server/mysql/mysql.sock") |
|
|
|
|
|
|
|
|
|
|
|
# import MySQLdb as mdb |
|
|
|
# import MySQLdb as mdb |
|
|
|
# dbconn = mdb.connect(host='localhost', port=3306, user='root', |
|
|
|
# dbconn = mdb.connect(host='localhost', port=3306, user='root', |
|
|
@ -400,11 +414,16 @@ def myOp(version, method): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def my8cmd(version, method): |
|
|
|
def my8cmd(version, method): |
|
|
|
# mysql 8.0 ok |
|
|
|
# mysql 8.0 and 5.7 ok |
|
|
|
init_file = initDreplace(version) |
|
|
|
init_file = initDreplace(version) |
|
|
|
cmd = init_file + ' ' + method |
|
|
|
cmd = init_file + ' ' + method |
|
|
|
try: |
|
|
|
|
|
|
|
|
|
|
|
if version == '5.7': |
|
|
|
|
|
|
|
initMysql57Data() |
|
|
|
|
|
|
|
elif version == '8.0': |
|
|
|
initMysql8Data() |
|
|
|
initMysql8Data() |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
|
|
|
|
if not mysql8IsInitedPasswd(): |
|
|
|
if not mysql8IsInitedPasswd(): |
|
|
|
setSkipGrantTables(True) |
|
|
|
setSkipGrantTables(True) |
|
|
|
cmd_init_start = init_file + ' start' |
|
|
|
cmd_init_start = init_file + ' start' |
|
|
@ -433,13 +452,13 @@ def my8cmd(version, method): |
|
|
|
sub.wait(5) |
|
|
|
sub.wait(5) |
|
|
|
return 'ok' |
|
|
|
return 'ok' |
|
|
|
except Exception as e: |
|
|
|
except Exception as e: |
|
|
|
print(e) |
|
|
|
return str(e) |
|
|
|
|
|
|
|
|
|
|
|
return 'fail' |
|
|
|
return 'fail' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def appCMD(version, action): |
|
|
|
def appCMD(version, action): |
|
|
|
if version == '8.0': |
|
|
|
if version == '8.0' or version == '5.7': |
|
|
|
return my8cmd(version, action) |
|
|
|
return my8cmd(version, action) |
|
|
|
return myOp(version, action) |
|
|
|
return myOp(version, action) |
|
|
|
|
|
|
|
|
|
|
|