Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $user_password = random_str(8);
- mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
- try {
- $conn = new mysqli($mysql_settings["client"]["host"], $mysql_settings["client"]["user"], $mysql_settings["client"]["password"]);
- } catch (Exception $ex) {
- echo "Service unavailable: ".$ex->getMessage()."\n";;
- exit(1);
- }
- $sql = "CREATE USER `".$result->options["name"]."`@`".$mysql_settings["client"]["host"]."` IDENTIFIED BY '".$user_password."'";
- try {
- if ($conn->query($sql) === TRUE) {
- echo "Successfully created database user: ".$result->options["name"]."`@`".$mysql_settings["client"]["host"]."\n";
- $conn->close();
- exit(0);
- }
- else{
- throw new Exception($conn->error);
- }
- } catch (Exception $ex) {
- echo "Error: ".$ex->getMessage()."\n";;
- $conn->close();
- exit(1);
- }
- $conn->close();
- }
Add Comment
Please, Sign In to add comment