Skip to content

Commit 2c9ab4c

Browse files
committed
fix: Use mariadb commands instead of mysql
1 parent 4ff4b8f commit 2c9ab4c

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

agent/bench.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def create_mariadb_user(self, site, mariadb_root_password, database=None):
266266
"FLUSH PRIVILEGES",
267267
]
268268
for query in queries:
269-
command = f"mysql -h {self.host} -uroot -p{mariadb_root_password}" f' -e "{query}"'
269+
command = f"mariadb -h {self.host} -uroot -p{mariadb_root_password}" f' -e "{query}"'
270270
self.execute(command)
271271
return database, user, password
272272

@@ -279,7 +279,7 @@ def drop_mariadb_user(self, site, mariadb_root_password, database=None):
279279
"FLUSH PRIVILEGES",
280280
]
281281
for query in queries:
282-
command = f"mysql -h {self.host} -uroot -p{mariadb_root_password}" f' -e "{query}"'
282+
command = f"mariadb -h {self.host} -uroot -p{mariadb_root_password}" f' -e "{query}"'
283283
self.execute(command)
284284

285285
def fetch_monitor_data(self):

agent/database_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def search_binary_log(
3636
log = os.path.join(self.mariadb_directory, log)
3737
LINES_TO_SKIP = r"^(USE|COMMIT|START TRANSACTION|DELIMITER|ROLLBACK|#)"
3838
command = (
39-
f"mysqlbinlog --short-form --database {database} "
39+
f"mariadb-binlog --short-form --database {database} "
4040
f"--start-datetime '{start_datetime}' "
4141
f"--stop-datetime '{stop_datetime}' "
4242
f" {log} | grep -Piv '{LINES_TO_SKIP}'"

agent/proxysql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self, directory=None):
1818

1919
def proxysql_execute(self, command):
2020
command = (
21-
"mysql -h 127.0.0.1 -P 6032 "
21+
"mariadb -h 127.0.0.1 -P 6032 "
2222
f"-u frappe -p{self.proxysql_admin_password} "
2323
f"--disable-column-names -e '{command}'"
2424
)

agent/site.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def create_database_access_credentials(self, mode, mariadb_root_password):
250250
"FLUSH PRIVILEGES",
251251
]
252252
for query in queries:
253-
command = f"mysql -h {self.host} -uroot -p{mariadb_root_password}" f' -e "{query}"'
253+
command = f"mariadb -h {self.host} -uroot -p{mariadb_root_password}" f' -e "{query}"'
254254
self.execute(command)
255255
return {"database": database, "user": user, "password": password}
256256

@@ -263,7 +263,7 @@ def revoke_database_access_credentials(self, user, mariadb_root_password):
263263
"FLUSH PRIVILEGES",
264264
]
265265
for query in queries:
266-
command = f"mysql -h {self.host} -uroot -p{mariadb_root_password}" f' -e "{query}"'
266+
command = f"mariadb -h {self.host} -uroot -p{mariadb_root_password}" f' -e "{query}"'
267267
self.execute(command)
268268
return {}
269269

@@ -291,7 +291,7 @@ def restore_site_tables(self):
291291
output = self.execute(
292292
"set -o pipefail && "
293293
f"gunzip -c '{backup_file_path}' | "
294-
f"mysql -h {self.host} -u {self.user} -p{self.password} "
294+
f"mariadb -h {self.host} -u {self.user} -p{self.password} "
295295
f"{self.database}",
296296
executable="/bin/bash",
297297
)
@@ -441,7 +441,7 @@ def tablewise_backup(self):
441441
backup_file = os.path.join(self.backup_directory, f"{table}.sql.gz")
442442
output = self.execute(
443443
"set -o pipefail && "
444-
"mysqldump --single-transaction --quick --lock-tables=false "
444+
"mariadb-dump --single-transaction --quick --lock-tables=false "
445445
f"-h {self.host} -u {self.user} -p{self.password} "
446446
f"{self.database} '{table}' "
447447
f" | gzip > '{backup_file}'",
@@ -523,7 +523,7 @@ def _restore_touched_tables(self):
523523
output = self.execute(
524524
"set -o pipefail && "
525525
f"gunzip -c '{backup_file}' | "
526-
f"mysql -h {self.host} -u {self.user} -p{self.password} "
526+
f"mariadb -h {self.host} -u {self.user} -p{self.password} "
527527
f"{self.database}",
528528
executable="/bin/bash",
529529
)
@@ -538,7 +538,7 @@ def drop_new_tables(self):
538538
data = {"dropped": {}}
539539
for table in new_tables:
540540
output = self.execute(
541-
f"mysql -h {self.host} -u {self.user} -p{self.password} "
541+
f"mariadb -h {self.host} -u {self.user} -p{self.password} "
542542
f"{self.database} -e 'DROP TABLE `{table}`'"
543543
)
544544
data["dropped"][table] = output
@@ -620,7 +620,7 @@ def timezone(self):
620620
)
621621
try:
622622
timezone = self.execute(
623-
f"mysql -h {self.host} -u{self.database} -p{self.password} "
623+
f"mariadb -h {self.host} -u{self.database} -p{self.password} "
624624
f'--connect-timeout 3 -sN -e "{query}"'
625625
)["output"].strip()
626626
except Exception:
@@ -630,7 +630,7 @@ def timezone(self):
630630
@property
631631
def tables(self):
632632
return self.execute(
633-
"mysql --disable-column-names -B -e 'SHOW TABLES' "
633+
"mariadb --disable-column-names -B -e 'SHOW TABLES' "
634634
f"-h {self.host} -u {self.user} -p{self.password} {self.database}"
635635
)["output"].split("\n")
636636

@@ -662,7 +662,7 @@ def optimize_tables(self):
662662
for table in tables:
663663
query = f"OPTIMIZE TABLE `{table}`"
664664
self.execute(
665-
f"mysql -sN -h {self.host} -u{self.user} -p{self.password}" f" {self.database} -e '{query}'"
665+
f"mariadb -sN -h {self.host} -u{self.user} -p{self.password}" f" {self.database} -e '{query}'"
666666
)
667667

668668
def fetch_latest_backup(self, with_files=True):
@@ -726,7 +726,7 @@ def get_database_size(self):
726726
f' WHERE `table_schema` = "{self.database}"'
727727
" GROUP BY `table_schema`"
728728
)
729-
command = f"mysql -sN -h {self.host} -u{self.user} -p{self.password}" f" -e '{query}'"
729+
command = f"mariadb -sN -h {self.host} -u{self.user} -p{self.password}" f" -e '{query}'"
730730
database_size = self.execute(command).get("output")
731731

732732
try:
@@ -772,7 +772,7 @@ def get_database_free_size(self):
772772
f' WHERE `table_schema` = "{self.database}"'
773773
" GROUP BY `table_schema`"
774774
)
775-
command = f"mysql -sN -h {self.host} -u{self.user} -p{self.password}" f" -e '{query}'"
775+
command = f"mariadb -sN -h {self.host} -u{self.user} -p{self.password}" f" -e '{query}'"
776776
database_size = self.execute(command).get("output")
777777

778778
try:
@@ -790,7 +790,7 @@ def get_database_free_tables(self):
790790
" AND ((`data_free` / (`data_length` + `index_length`)) > 0.2"
791791
" OR `data_free` > 100 * 1024 * 1024)"
792792
)
793-
command = f"mysql -sN -h {self.host} -u{self.user} -p{self.password}" f" -e '{query}'"
793+
command = f"mariadb -sN -h {self.host} -u{self.user} -p{self.password}" f" -e '{query}'"
794794
output = self.execute(command).get("output")
795795
return [line.split("\t") for line in output.splitlines()]
796796
except Exception:

0 commit comments

Comments
 (0)