do check for remote db

This commit is contained in:
Usman Nasir
2021-03-04 09:22:06 +05:00
parent 2509c7985a
commit 8ece4f4b3b
2 changed files with 13 additions and 2 deletions

View File

@@ -274,7 +274,6 @@ class InstallCyberPanel:
def changeMYSQLRootPassword(self):
if self.remotemysql == 'OFF':
if self.distro == ubuntu:
passwordCMD = "use mysql;DROP DATABASE IF EXISTS test;DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%%';GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '%s';UPDATE user SET plugin='' WHERE User='root';flush privileges;" % (InstallCyberPanel.mysql_Root_password)
else:

View File

@@ -14,7 +14,6 @@ class mysqlUtilities:
from json import loads
mysqlData = loads(open("/etc/cyberpanel/mysqlPassword", 'r').read())
initCommand = 'mysql -h %s --port %s -u %s -p%s -e "' % (mysqlData['mysqlhost'], mysqlData['mysqlport'], mysqlData['mysqluser'], mysqlData['mysqlpassword'])
remote = 1
except:
@@ -56,6 +55,19 @@ class mysqlUtilities:
if res == 1:
return 0
else:
### DO Check
if mysqlData['mysqlhost'].find('ondigitalocean') > -1:
alterUserPassword = "ALTER USER 'cyberpanel'@'%s' IDENTIFIED WITH mysql_native_password BY '%s'" % (publicip, dbpassword)
command = initCommand + alterUserPassword + '"'
if install.preFlightsChecks.debug:
print(command)
time.sleep(10)
cmd = shlex.split(command)
subprocess.call(cmd)
if remote:
if mysqlData['mysqlhost'].find('rds.amazon') == -1:
dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (publicip)