protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption("password")) {
         $password = $input->getOption("password");
     } else {
         $question = new Question('Password: '******'question');
         $password = $helper->ask($input, $output, $question);
     }
     $server = new Server\Database\Mysql();
     $server->setHostname($input->getArgument("host"));
     $server->setUser("provisioning");
     $server->setPassword($this->createPassword());
     $server->setDatabase("provisioning");
     $server->setMode($input->getArgument("mode"));
     $server->setType($input->getArgument("type"));
     $server->setActive(false);
     // convert errors to PDOExceptions
     $options = [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION];
     $dsn = sprintf("mysql:host=%s;port=%s;charset=utf8", $server->getHostname(), 3306);
     $pdo = new \PDO($dsn, $input->getArgument("user"), $password, $options);
     $pdo->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
     $pdo->exec("SET NAMES utf8;");
     $pdo->exec("CREATE USER '{$server->getUser()}'@'%' IDENTIFIED BY '{$server->getPassword()}';");
     $pdo->exec("GRANT CREATE, DROP, GRANT OPTION, LOCK TABLES, REFERENCES, EVENT, ALTER, DELETE, INDEX, INSERT, SELECT, UPDATE, CREATE TEMPORARY TABLES, TRIGGER, CREATE VIEW, SHOW VIEW, ALTER ROUTINE, CREATE ROUTINE, EXECUTE, CREATE USER, PROCESS, RELOAD, REPLICATION CLIENT, REPLICATION SLAVE, SHOW DATABASES, USAGE ON *.* TO '{$server->getUser()}' WITH GRANT OPTION;");
     $pdo->exec("CREATE DATABASE {$server->getDatabase()} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;");
     // Write to DB
     $entityManager = $this->getProvisioningServer("mysql")->getEntityManager();
     $entityManager->persist($server);
     $entityManager->flush();
     $table = $this->getMySqlServersTable([$server], $output);
     $table->render();
 }
 /**
  * @param Request $request
  * @return Response
  */
 public function addMySQLServerAction(Request $request)
 {
     $this->checkTokenPermissions();
     $server = new Mysql();
     $server->setHostname($request->get("host", null));
     $server->setUser($request->get("user", null));
     $server->setPassword($request->get("password", null));
     $server->setDatabase($request->get("database", null));
     $server->setMode($request->get("mode", null));
     $server->setType($request->get("type", null));
     $server->setActive(false);
     // Write to DB
     $entityManager = $this->getProvisioningServer("mysql")->getEntityManager();
     $entityManager->persist($server);
     $entityManager->flush();
     $response = $server->toList(false);
     return $this->returnJson($response, 201);
 }