Fix netdata mysql user in case of reinstall

This commit is contained in:
VirtuBox
2019-12-06 13:09:45 +01:00
parent d536f57cd9
commit 0e12bc29db
2 changed files with 13 additions and 13 deletions

View File

@@ -1410,11 +1410,15 @@ def post_pref(self, apt_packages, packages, upgrade=False):
try:
WOMysql.execute(
self,
"create user 'netdata'@'localhost';",
"DELETE FROM mysql.user WHERE User = 'netdata';",
log=False)
WOMysql.execute(
self,
"grant usage on *.* to 'netdata'@'localhost';",
"create user 'netdata'@'127.0.0.1';",
log=False)
WOMysql.execute(
self,
"grant usage on *.* to 'netdata'@'127.0.0.1';",
log=False)
WOMysql.execute(
self, "flush privileges;",

View File

@@ -108,17 +108,13 @@ class WOMysql():
if dbs == "":
continue
Log.info(self, "Backing up {0} database".format(dbs))
p1 = subprocess.Popen("/usr/bin/mysqldump {0}"
" --max_allowed_packet=1024M"
" --single-transaction".format(dbs),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE, shell=True)
p2 = subprocess.Popen("/usr/bin/pigz -c > "
"/var/lib/wo-backup/mysql/{0}{1}.sql.gz"
.format(dbs, WOVar.wo_date),
stdin=p1.stdout,
shell=True)
p1 = subprocess.Popen(
"/usr/bin/mysqldump {0} --max_allowed_packet=1024M "
"--single-transaction ".format(dbs),
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
p2 = subprocess.Popen(
"/usr/bin/pigz -c > /var/lib/wo-backup/mysql/{0}{1}.sql.gz"
.format(dbs, WOVar.wo_date), stdin=p1.stdout, shell=True)
# Allow p1 to receive a SIGPIPE if p2 exits
p1.stdout.close()
output = p1.stderr.read()