Skip to content
Snippets Groups Projects
Unverified Commit aeb40112 authored by Vincent Petry's avatar Vincent Petry Committed by Bjoern Schiessle
Browse files

Fix misleading MySQL DB creation error (#25485)

Whenever the GRANT ALL failed, it used to display "Database creation
failed" which is incorrect. It's only the privleges setting that failed.

This moves the privilege setting message to DEBUG and makes it more
precise.
parent 318d68a9
No related branches found
No related tags found
No related merge requests found
...@@ -61,12 +61,20 @@ class MySQL extends AbstractDatabase { ...@@ -61,12 +61,20 @@ class MySQL extends AbstractDatabase {
//we can't use OC_BD functions here because we need to connect as the administrative user. //we can't use OC_BD functions here because we need to connect as the administrative user.
$query = "CREATE DATABASE IF NOT EXISTS `$name` CHARACTER SET utf8 COLLATE utf8_bin;"; $query = "CREATE DATABASE IF NOT EXISTS `$name` CHARACTER SET utf8 COLLATE utf8_bin;";
$connection->executeUpdate($query); $connection->executeUpdate($query);
} catch (\Exception $ex) {
$this->logger->error('Database creation failed: {error}', [
'app' => 'mysql.setup',
'error' => $ex->getMessage()
]);
return;
}
try {
//this query will fail if there aren't the right permissions, ignore the error //this query will fail if there aren't the right permissions, ignore the error
$query="GRANT ALL PRIVILEGES ON `$name` . * TO '$user'"; $query="GRANT ALL PRIVILEGES ON `$name` . * TO '$user'";
$connection->executeUpdate($query); $connection->executeUpdate($query);
} catch (\Exception $ex) { } catch (\Exception $ex) {
$this->logger->error('Database creation failed: {error}', [ $this->logger->debug('Could not automatically grant privileges, this can be ignored if database user already had privileges: {error}', [
'app' => 'mysql.setup', 'app' => 'mysql.setup',
'error' => $ex->getMessage() 'error' => $ex->getMessage()
]); ]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment