added create db script

This commit is contained in:
Andreas 2019-09-10 14:52:21 +02:00
parent 92a9c62a2d
commit f061752bdf

View File

@ -0,0 +1,24 @@
<?php
$host="172.21.0.3"; //docker sql container bridge ip
$root="root";
$root_password="rootpass";
$user='forumadmin';
$pass='doesntmatter';
$db="webforum";
try {
$dbh = new PDO("mysql:host=$host", $root, $root_password);
$dbh->exec("CREATE DATABASE `$db`;
CREATE USER '$user'@'localhost' IDENTIFIED BY '$pass';
GRANT ALL ON `$db`.* TO '$user'@'localhost';
FLUSH PRIVILEGES;")
or die(print_r($dbh->errorInfo(), true));
} catch (PDOException $e) {
die("DB ERROR: ". $e->getMessage());
}
?>