Better error message when missing grant privileges
This commit is contained in:
parent
06e0ec5e0c
commit
d3d0ce4649
@ -930,11 +930,17 @@ class DoliDBMysqli extends DoliDB
|
||||
dol_syslog(get_class($this)."::DDLCreateUser sql=".$sql, LOG_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
// Redo with localhost forced (sometimes user is created on %)
|
||||
$sql = "CREATE USER '".$this->escape($dolibarr_main_db_user)."'@'localhost'";
|
||||
$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)."'";
|
||||
dol_syslog(get_class($this)."::DDLCreateUser", LOG_DEBUG); // No sql to avoid password in log
|
||||
$resql=$this->query($sql);
|
||||
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 '*****'";
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@ -573,6 +573,7 @@ if (! $error && $db->connected && $action == "set")
|
||||
|
||||
// Create user
|
||||
$result=$db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
|
||||
|
||||
// Create user bis
|
||||
if ($databasefortest == 'mysql')
|
||||
{
|
||||
@ -611,7 +612,7 @@ if (! $error && $db->connected && $action == "set")
|
||||
print $langs->trans("UserCreation").' : ';
|
||||
print $dolibarr_main_db_user;
|
||||
print '</td>';
|
||||
print '<td>'.$langs->trans("Error").': '.$db->errno().' '.$db->error()."</td></tr>";
|
||||
print '<td>'.$langs->trans("Error").': '.$db->errno().' '.$db->error().($db->error ? '. '.$db->error : '')."</td></tr>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user