diff options
author | Paul Arthur <paul.arthur@flowerysong.com> | 2013-05-27 19:36:24 -0400 |
---|---|---|
committer | Paul Arthur <paul.arthur@flowerysong.com> | 2013-05-27 19:37:12 -0400 |
commit | eac07ede274d19840574da4b6a4593b7d632e711 (patch) | |
tree | 3c19b7e98fb83d77d2228d285ed638b9c2df0a3e /lib | |
parent | c311581b5cce0b8d2b4400b48f20809965ffafdf (diff) | |
download | ampache-eac07ede274d19840574da4b6a4593b7d632e711.tar.gz ampache-eac07ede274d19840574da4b6a4593b7d632e711.tar.bz2 ampache-eac07ede274d19840574da4b6a4593b7d632e711.zip |
install: Add support for MySQL sockets
If we're using a socket, grant privileges to user@localhost, not
user@socketname.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/install.lib.php | 10 |
1 files changed, 7 insertions, 3 deletions
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; |