diff --git a/agent/site.py b/agent/site.py index bce0f65..72c8cce 100644 --- a/agent/site.py +++ b/agent/site.py @@ -309,7 +309,7 @@ def create_database_access_credentials(self, mode, mariadb_root_password): ] for query in queries: command = ( - f"mysql -h {self.host} -uroot -p{mariadb_root_password}" + f"mysql -h {self.host} -uroot -p{mariadb_root_password} -P {self.port}" f' -e "{query}"' ) self.execute(command) @@ -325,7 +325,7 @@ def revoke_database_access_credentials(self, user, mariadb_root_password): ] for query in queries: command = ( - f"mysql -h {self.host} -uroot -p{mariadb_root_password}" + f"mysql -h {self.host} -uroot -p{mariadb_root_password} -P {self.port}" f' -e "{query}"' ) self.execute(command) @@ -355,7 +355,7 @@ def restore_site_tables(self): output = self.execute( "set -o pipefail && " f"gunzip -c '{backup_file_path}' | " - f"mysql -h {self.host} -u {self.user} -p{self.password} " + f"mysql -h {self.host} -u {self.user} -p{self.password} -P {self.port}" f"{self.database}", executable="/bin/bash", ) @@ -504,7 +504,7 @@ def tablewise_backup(self): "set -o pipefail && " "mysqldump --single-transaction --quick --lock-tables=false " f"-h {self.host} -u {self.user} -p{self.password} " - f"{self.database} '{table}' " + f"{self.database} -P {self.port} '{table}' " f" | gzip > '{backup_file}'", executable="/bin/bash", ) @@ -572,7 +572,7 @@ def restore_touched_tables(self): output = self.execute( "set -o pipefail && " f"gunzip -c '{backup_file}' | " - f"mysql -h {self.host} -u {self.user} -p{self.password} -P{self.port}" + f"mysql -h {self.host} -u {self.user} -p{self.password} -P {self.port}" f"{self.database}", executable="/bin/bash", ) @@ -587,7 +587,7 @@ def drop_new_tables(self): data = {"dropped": {}} for table in new_tables: output = self.execute( - f"mysql -h {self.host} -u {self.user} -p{self.password} " + f"mysql -h {self.host} -u {self.user} -p{self.password} -P {self.port}" f"{self.database} -e 'DROP TABLE `{table}`'" ) data["dropped"][table] = output @@ -669,7 +669,7 @@ def timezone(self): ) try: timezone = self.execute( - f"mysql -h {self.host} -u{self.database} -p{self.password} " + f"mysql -h {self.host} -u{self.database} -p{self.password} -P {self.port}" f'-sN -e "{query}"' )["output"].strip() except Exception: @@ -680,7 +680,7 @@ def timezone(self): def tables(self): return self.execute( "mysql --disable-column-names -B -e 'SHOW TABLES' " - f"-h {self.host} -u {self.user} -p{self.password} {self.database}" + f"-h {self.host} -u {self.user} -p{self.password} -P {self.port} {self.database}" )["output"].split("\n") @property @@ -713,7 +713,7 @@ def optimize_tables(self): for table in tables: query = f"OPTIMIZE TABLE `{table}`" self.execute( - f"mysql -sN -h {self.host} -u{self.user} -p{self.password}" + f"mysql -sN -h {self.host} -u{self.user} -p{self.password} -P {self.port}" f" {self.database} -e '{query}'" ) @@ -789,7 +789,7 @@ def get_database_size(self): " GROUP BY `table_schema`" ) command = ( - f"mysql -sN -h {self.host} -u{self.user} -p{self.password}" + f"mysql -sN -h {self.host} -u{self.user} -p{self.password} -P {self.port}" f" -e '{query}'" ) database_size = self.execute(command).get("output") @@ -838,7 +838,7 @@ def get_database_free_size(self): " GROUP BY `table_schema`" ) command = ( - f"mysql -sN -h {self.host} -u{self.user} -p{self.password}" + f"mysql -sN -h {self.host} -u{self.user} -p{self.password} -P {self.port}" f" -e '{query}'" ) database_size = self.execute(command).get("output") @@ -859,7 +859,7 @@ def get_database_free_tables(self): " OR `data_free` > 100 * 1024 * 1024)" ) command = ( - f"mysql -sN -h {self.host} -u{self.user} -p{self.password}" + f"mysql -sN -h {self.host} -u{self.user} -p{self.password} -P {self.port}" f" -e '{query}'" ) output = self.execute(command).get("output")