diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index a0dede0a895..2748a88cc98 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -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; } diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index c37dee6570a..508f60cfd9a 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -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 ''; - print ''.$langs->trans("Error").': '.$db->errno().' '.$db->error().""; + print ''.$langs->trans("Error").': '.$db->errno().' '.$db->error().($db->error ? '. '.$db->error : '').""; } }