/**
  * @param Account $account
  */
 public function revokePermissions(Account $account)
 {
     $conn = $this->connect();
     try {
         $conn->exec("REVOKE ALL PRIVILEGES, GRANT OPTION FROM '{$account->getUser()}';");
         $conn->exec("FLUSH PRIVILEGES;");
     } catch (\Exception $e) {
         $this->logException(Logger::ERROR, "Can't revoke all permissions for '{$account->getUser()}'@'{$account->getHostname()}'.", $e);
     }
     $conn->close();
 }
 /**
  * @param Account $account
  */
 public function removeAccount(Account $account)
 {
     $servers = $this->getServersByHostname($account->getHostname());
     if (!$servers || !isset($servers[0]) || !$servers[0]) {
         return;
     }
     $server = $servers[0];
     if ($account->getGroupId()) {
         $accounts = $this->getAccountRepository()->findBy(array("hostname" => $account->getHostname(), "groupId" => $account->getGroupId(), "active" => true));
         $otherAccounts = array();
         foreach ($accounts as $item) {
             if ($item->getId() != $account->getId()) {
                 $otherAccounts[] = $item;
             }
         }
         if (!count($otherAccounts)) {
             $server->dropAccount($account);
         } else {
             try {
                 $server->killProcesses($account);
                 $server->revokePermission($account, $account->getDatabase());
             } catch (InvalidCredentialsException $e) {
                 // Skip this exception
             }
         }
     } else {
         $server->dropAccount($account);
     }
 }