mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 14:14:04 +00:00
Use % for CREATE % GRANT queries
This commit is contained in:
parent
1329356b4b
commit
e6e4548a22
5 changed files with 61 additions and 6 deletions
|
|
@ -30,14 +30,14 @@ class PermissionControlledMySQLDatabaseManager extends MySQLDatabaseManager impl
|
|||
throw new TenantDatabaseUserAlreadyExistsException($username);
|
||||
}
|
||||
|
||||
$this->database()->statement("CREATE USER `{$username}`@`{$hostname}` IDENTIFIED BY '{$password}'");
|
||||
$this->database()->statement("CREATE USER `{$username}`@`%` IDENTIFIED BY '{$password}'");
|
||||
|
||||
$grants = implode(', ', static::$grants);
|
||||
|
||||
if ($this->isVersion8()) { // MySQL 8+
|
||||
$grantQuery = "GRANT $grants ON `$database`.* TO `$username`@`$hostname`";
|
||||
$grantQuery = "GRANT $grants ON `$database`.* TO `$username`@`%`";
|
||||
} else { // MySQL 5.7
|
||||
$grantQuery = "GRANT $grants ON `$database`.* TO `$username`@`$hostname` IDENTIFIED BY '$password'";
|
||||
$grantQuery = "GRANT $grants ON `$database`.* TO `$username`@`%` IDENTIFIED BY '$password'";
|
||||
}
|
||||
|
||||
return $this->database()->statement($grantQuery);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue