]> source.dussan.org Git - nextcloud-server.git/commitdiff
Added Exception catch in case of DB User exists 1958/head
authorHemanth Kumar Veeranki <hems.india1997@gmail.com>
Mon, 31 Oct 2016 11:02:22 +0000 (16:32 +0530)
committerHemanth Kumar Veeranki <hems.india1997@gmail.com>
Mon, 31 Oct 2016 11:02:22 +0000 (16:32 +0530)
Signed-off-by: Hemanth Kumar Veeranki <hemanthveeranki@gmail.com>
lib/private/Setup/MySQL.php

index c022616d8b3d6113618c06ed7866f9ae4eb5136c..d1399c8821c05c05635a1a195281f718b45897d5 100644 (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()
+                        ]);
+               }
        }
 
        /**