added database password generation
Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
parent
2e779ed606
commit
c5f2d3044e
|
@ -94,15 +94,26 @@ class DatabaseConnection
|
||||||
echo $exception->getMessage() . PHP_EOL;
|
echo $exception->getMessage() . PHP_EOL;
|
||||||
echo 'Did you create the database and adjust the config file?' . PHP_EOL;
|
echo 'Did you create the database and adjust the config file?' . PHP_EOL;
|
||||||
echo PHP_EOL . 'You can create database an user via a panel or manually in mysql shell:' . PHP_EOL;
|
echo PHP_EOL . 'You can create database an user via a panel or manually in mysql shell:' . PHP_EOL;
|
||||||
echo 'CREATE DATABASE databasename;' . PHP_EOL;
|
$password = $this->generatePassword();
|
||||||
echo "CREATE USER 'user'@'localhost' IDENTIFIED BY 'secret';" . PHP_EOL;
|
echo 'Created an initial password: ' . $password . PHP_EOL;
|
||||||
echo "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, INDEX, DROP, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON databasename.* TO 'user'@'localhost';" . PHP_EOL;
|
echo 'CREATE DATABASE bindAPI;' . PHP_EOL;
|
||||||
|
echo "CREATE USER 'bindAPI'@'localhost' IDENTIFIED BY '$password';" . PHP_EOL;
|
||||||
|
echo "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, INDEX, DROP, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON bindAPI.* TO 'bindAPI'@'localhost';" . PHP_EOL;
|
||||||
echo 'There is no need to run FLUSH PRIVILEGES when using GRANT!' . PHP_EOL;
|
echo 'There is no need to run FLUSH PRIVILEGES when using GRANT!' . PHP_EOL;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function generatePassword($length = 8) {
|
||||||
|
|
||||||
|
$chars = '23456789bcdfhkmnprstvzBCDFHJKLMNPRSTVZ';
|
||||||
|
$shuffled = str_shuffle($chars);
|
||||||
|
$result = mb_substr($shuffled, 0, $length);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \PDO
|
* @return \PDO
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue