34132-vm/db/create_db.php
Flatlogic Bot 05d192f46f MagiCV
2025-09-17 11:37:51 +00:00

19 lines
529 B
PHP

<?php
require_once __DIR__ . '/config.php';
try {
// Connect to MySQL server without specifying a database
$pdo = new PDO('mysql:host='.DB_HOST, DB_USER, DB_PASS, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]);
// Create the database if it doesn't exist
$pdo->exec("CREATE DATABASE IF NOT EXISTS `" . DB_NAME . "`");
echo "Database '" . DB_NAME . "' created successfully or already exists.\n";
} catch (PDOException $e) {
die("Database creation failed: " . $e->getMessage() . "\n");
}