24 lines
591 B
PHP
24 lines
591 B
PHP
<?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());
|
|
}
|
|
?>
|