diff --git a/core/Command/Db/DbInfo.php b/core/Command/Db/DbInfo.php
index f844e6fe65213..08d662043e3b3 100644
--- a/core/Command/Db/DbInfo.php
+++ b/core/Command/Db/DbInfo.php
@@ -9,6 +9,7 @@
namespace OC\Core\Command\Db;
+use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
@@ -76,11 +77,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
private function getMySQLInfo(): array {
- $result = $this->connection->executeQuery(
- 'SELECT VERSION() AS version, @@innodb_buffer_pool_size AS buffer_pool,
+ try {
+ return $this->getMySQLInfoUsingQuery(
+ 'SELECT VERSION() AS version, @@innodb_buffer_pool_size AS buffer_pool,
@@max_connections AS max_conn, @@character_set_database AS charset,
@@transaction_isolation AS tx_isolation'
- );
+ );
+ } catch (DriverException $e) {
+ return $this->getMySQLInfoUsingQuery('SELECT VERSION() AS version, @@innodb_buffer_pool_size AS buffer_pool,
+ @@max_connections AS max_conn, @@character_set_database AS charset,
+ @@tx_isolation AS tx_isolation');
+ }
+ }
+
+ private function getMySQLInfoUsingQuery(string $query): array {
+ $result = $this->connection->executeQuery($query);
$info = $result->fetchAssociative();
$bufferPoolGB = round(($info['buffer_pool'] / 1024 / 1024 / 1024), 2);
diff --git a/core/Command/Db/DbLocks.php b/core/Command/Db/DbLocks.php
index 4bb336e9db884..6eb583cd80e58 100644
--- a/core/Command/Db/DbLocks.php
+++ b/core/Command/Db/DbLocks.php
@@ -9,6 +9,7 @@
namespace OC\Core\Command\Db;
+use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use OC\DB\Connection;
@@ -74,7 +75,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return Command::SUCCESS;
}
- $rows = $this->connection->executeQuery($sql)->fetchAllAssociative();
+ try {
+ $rows = $this->connection->executeQuery($sql)->fetchAllAssociative();
+ } catch (DriverException $e) {
+ if ($e->getCode() === 1227) {
+ $output->writeln('The configured database user doesn\'t have permissions to query active locks, PROCESS privilege required.');
+ } else {
+ $output->writeln('Failed to query active locks: ' . $e->getMessage() . '.');
+ }
+ return Command::FAILURE;
+ }
if (empty($rows)) {
$output->writeln('No active locks or blocking transactions detected.');
diff --git a/core/Command/Db/DbSize.php b/core/Command/Db/DbSize.php
index ceec7d8c18e51..8cd41b41fe8c4 100644
--- a/core/Command/Db/DbSize.php
+++ b/core/Command/Db/DbSize.php
@@ -45,7 +45,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
ROUND((data_length + index_length) / 1024 / 1024, 2) AS total_mb,
ROUND(data_length / 1024 / 1024, 2) AS data_mb,
ROUND(index_length / 1024 / 1024, 2) AS index_mb,
- table_rows AS rows,
+ table_rows AS `rows`,
IF(table_rows > 0, ROUND((data_length + index_length) / table_rows, 0), 0) AS avg_row_bytes
FROM information_schema.tables
WHERE table_schema = DATABASE()