<?php
try {
    $pdo = new PDO('mysql:host=127.0.0.1;port=3306', 'root', 'admin', [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
    $user = 'rapbrgdf_user';
    $pass = 'admin';
    $pdo->exec("CREATE USER IF NOT EXISTS '$user'@'127.0.0.1' IDENTIFIED BY '$pass';");
    $pdo->exec("GRANT ALL PRIVILEGES ON `rapbrgdf`.* TO '$user'@'127.0.0.1';");
    $pdo->exec('FLUSH PRIVILEGES;');
    echo "User $user created/granted for database rapbrgdf\n";
} catch (Throwable $e) {
    echo 'ERROR: ' . $e->getMessage() . "\n";
    exit(1);
}
