Last active
June 13, 2018 12:34
-
-
Save NBZ4live/e48d24c948a2be93ae5c9fc5eeaaf779 to your computer and use it in GitHub Desktop.
Print MySQL Grants for all not working connections configured in Laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$userHost = '%'; | |
foreach(config('database.connections') as $name => $connection) { | |
if ($connection['driver'] != 'mysql') { | |
continue; | |
} | |
try { | |
\DB::connection($name)->getPdo(); | |
} catch(\Doctrine\DBAL\Driver\PDOException $exception) { | |
$host = $connection['host'] ?? $connection['write']['host']; | |
print "{$name}({$host}) --- GRANT ALL ON {$connection['database']}.* TO '{$connection['username']}'@'{$userHost}' IDENTIFIED BY \"{$connection['password']}\";\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment