diff --git a/frappe/commands/utils.py b/frappe/commands/utils.py index d0024aed73..3658a35992 100644 --- a/frappe/commands/utils.py +++ b/frappe/commands/utils.py @@ -523,22 +523,24 @@ def postgres(context): def _mariadb(): + from frappe.database.mariadb.database import MariaDBDatabase + mysql = find_executable("mysql") - os.execv( + command = [ mysql, - [ - mysql, - "-u", - frappe.conf.db_name, - "-p" + frappe.conf.db_password, - frappe.conf.db_name, - "-h", - frappe.conf.db_host or "localhost", - "--pager=less -SFX", - "--safe-updates", - "-A", - ], - ) + "--port", + frappe.conf.db_port or MariaDBDatabase.default_port, + "-u", + frappe.conf.db_name, + f"-p{frappe.conf.db_password}", + frappe.conf.db_name, + "-h", + frappe.conf.db_host or "localhost", + "--pager=less -SFX", + "--safe-updates", + "-A", + ] + os.execv(mysql, command) def _psql(): diff --git a/frappe/database/mariadb/database.py b/frappe/database/mariadb/database.py index e89168194e..4bdc1688e9 100644 --- a/frappe/database/mariadb/database.py +++ b/frappe/database/mariadb/database.py @@ -143,6 +143,7 @@ class MariaDBDatabase(MariaDBConnectionUtil, MariaDBExceptionUtil, Database): FIELD_TYPE.DATETIME: get_datetime, UnicodeWithAttrs: escape_string, } + default_port = "3306" def setup_type_map(self): self.db_type = "mariadb" diff --git a/frappe/database/postgres/database.py b/frappe/database/postgres/database.py index 85e4f2f0f7..58b63e6547 100644 --- a/frappe/database/postgres/database.py +++ b/frappe/database/postgres/database.py @@ -108,6 +108,7 @@ class PostgresDatabase(PostgresExceptionUtil, Database): # to the next non-cached value hence not using cache in postgres. # ref: https://stackoverflow.com/questions/21356375/postgres-9-0-4-sequence-skipping-numbers SEQUENCE_CACHE = 0 + default_port = "5432" def setup_type_map(self): self.db_type = "postgres" diff --git a/frappe/tests/test_db.py b/frappe/tests/test_db.py index bb64d0278d..b658919ef5 100644 --- a/frappe/tests/test_db.py +++ b/frappe/tests/test_db.py @@ -97,7 +97,6 @@ class TestDB(unittest.TestCase): ) def test_get_value_limits(self): - # check both dict and list style filters filters = [{"enabled": 1}, [["enabled", "=", 1]]] for filter in filters: diff --git a/frappe/utils/backups.py b/frappe/utils/backups.py index e6068fd299..f7b38b0055 100644 --- a/frappe/utils/backups.py +++ b/frappe/utils/backups.py @@ -73,11 +73,7 @@ class BackupGenerator: if not self.db_type: self.db_type = "mariadb" - if not self.db_port: - if self.db_type == "mariadb": - self.db_port = 3306 - if self.db_type == "postgres": - self.db_port = 5432 + self.db_port = self.db_port or frappe.db.default_port site = frappe.local.site or frappe.generate_hash(length=8) self.site_slug = site.replace(".", "_")