Merge pull request #1958 from harry-7/1428issue

Added Exception catch and ignore for DBuser exists
This commit is contained in:
Lukas Reschke 2016-11-02 20:22:48 +01:00 committed by GitHub
commit f7d681d038
1 changed files with 16 additions and 8 deletions

View File

@ -87,14 +87,22 @@ class MySQL extends AbstractDatabase {
* @throws \OC\DatabaseSetupException
*/
private function createDBUser($connection) {
$name = $this->dbUser;
$password = $this->dbPassword;
// we need to create 2 accounts, one for global use and one for local user. if we don't specify the local one,
// the anonymous user would take precedence when there is one.
$query = "CREATE USER '$name'@'localhost' IDENTIFIED BY '$password'";
$connection->executeUpdate($query);
$query = "CREATE USER '$name'@'%' IDENTIFIED BY '$password'";
$connection->executeUpdate($query);
try{
$name = $this->dbUser;
$password = $this->dbPassword;
// we need to create 2 accounts, one for global use and one for local user. if we don't specify the local one,
// the anonymous user would take precedence when there is one.
$query = "CREATE USER '$name'@'localhost' IDENTIFIED BY '$password'";
$connection->executeUpdate($query);
$query = "CREATE USER '$name'@'%' IDENTIFIED BY '$password'";
$connection->executeUpdate($query);
}
catch (\Exception $ex){
$this->logger->error('Database User creation failed: {error}', [
'app' => 'mysql.setup',
'error' => $ex->getMessage()
]);
}
}
/**