From eac07ede274d19840574da4b6a4593b7d632e711 Mon Sep 17 00:00:00 2001 From: Paul Arthur Date: Mon, 27 May 2013 19:36:24 -0400 Subject: install: Add support for MySQL sockets If we're using a socket, grant privileges to user@localhost, not user@socketname. --- lib/install.lib.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/install.lib.php b/lib/install.lib.php index a889d65d..899e4925 100644 --- a/lib/install.lib.php +++ b/lib/install.lib.php @@ -155,9 +155,13 @@ function install_insert_db($db_user = null, $db_pass = null, $overwrite = false) // Check to see if we should create a user here if (strlen($db_user) && strlen($db_pass)) { - $sql = 'GRANT ALL PRIVILEGES ON `' . Dba::escape($database) . '`.* TO ' . - "'" . Dba::escape($db_user) . "'@'" . Dba::escape(Config::get('database_hostname')) . "' IDENTIFIED BY '" . Dba::escape($db_pass) . "' WITH GRANT OPTION"; - + $db_host = Config::get('database_hostname'); + if (strpos($db_host, '/') === 0) { + $db_host = 'localhost'; + } + $sql = 'GRANT ALL PRIVILEGES ON `' . Dba::escape($database) . '`.* TO ' . + "'" . Dba::escape($db_user) . "'@'" . Dba::escape($db_host) . "' " . + "IDENTIFIED BY '" . Dba::escape($db_pass) . "' WITH GRANT OPTION"; if (!Dba::write($sql)) { Error::add('general', sprintf(T_('Error: Unable to Insert %1$s with permissions to %2$s on %3$s %4$s'), $db_user, $database, $hostname, Dba::error())); return false; -- cgit