Merge pull request #19703 from atm-maxime/fix_mysql8_createuser
Fix #19662 : mysql8 user creation in 2 steps
This commit is contained in:
commit
5f7abc0f8c
@ -966,7 +966,7 @@ class DoliDBMysqli extends DoliDB
|
|||||||
public function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name)
|
public function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
$sql = "CREATE USER '".$this->escape($dolibarr_main_db_user)."'";
|
$sql = "CREATE USER '".$this->escape($dolibarr_main_db_user)."' IDENTIFIED BY '".$this->escape($dolibarr_main_db_pass)."'";
|
||||||
dol_syslog(get_class($this)."::DDLCreateUser", LOG_DEBUG); // No sql to avoid password in log
|
dol_syslog(get_class($this)."::DDLCreateUser", LOG_DEBUG); // No sql to avoid password in log
|
||||||
$resql = $this->query($sql);
|
$resql = $this->query($sql);
|
||||||
if (!$resql) {
|
if (!$resql) {
|
||||||
@ -979,14 +979,14 @@ class DoliDBMysqli extends DoliDB
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Redo with localhost forced (sometimes user is created on %)
|
// Redo with localhost forced (sometimes user is created on %)
|
||||||
$sql = "CREATE USER '".$this->escape($dolibarr_main_db_user)."'@'localhost'";
|
$sql = "CREATE USER '".$this->escape($dolibarr_main_db_user)."'@'localhost' IDENTIFIED BY '".$this->escape($dolibarr_main_db_pass)."'";
|
||||||
$resql = $this->query($sql);
|
$resql = $this->query($sql);
|
||||||
|
|
||||||
$sql = "GRANT ALL PRIVILEGES ON ".$this->escape($dolibarr_main_db_name).".* TO '".$this->escape($dolibarr_main_db_user)."'@'".$this->escape($dolibarr_main_db_host)."' IDENTIFIED BY '".$this->escape($dolibarr_main_db_pass)."'";
|
$sql = "GRANT ALL PRIVILEGES ON ".$this->escape($dolibarr_main_db_name).".* TO '".$this->escape($dolibarr_main_db_user)."'@'".$this->escape($dolibarr_main_db_host)."'";
|
||||||
dol_syslog(get_class($this)."::DDLCreateUser", LOG_DEBUG); // No sql to avoid password in log
|
dol_syslog(get_class($this)."::DDLCreateUser", LOG_DEBUG); // No sql to avoid password in log
|
||||||
$resql = $this->query($sql);
|
$resql = $this->query($sql);
|
||||||
if (!$resql) {
|
if (!$resql) {
|
||||||
$this->error = "Connected user not allowed to GRANT ALL PRIVILEGES ON ".$this->escape($dolibarr_main_db_name).".* TO '".$this->escape($dolibarr_main_db_user)."'@'".$this->escape($dolibarr_main_db_host)."' IDENTIFIED BY '*****'";
|
$this->error = "Connected user not allowed to GRANT ALL PRIVILEGES ON ".$this->escape($dolibarr_main_db_name).".* TO '".$this->escape($dolibarr_main_db_user)."'@'".$this->escape($dolibarr_main_db_host)."'";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user