diff --git a/conf/default.conf.php b/conf/default.conf.php index cc81db6019..5a8fa92fda 100644 --- a/conf/default.conf.php +++ b/conf/default.conf.php @@ -75,7 +75,9 @@ return array( // The password to use when connecting to MySQL. 'mysql.pass' => '', - // The MySQL server to connect to. + // The MySQL server to connect to. If you want to connect to a different + // port than the default (which is 3306), specify it in the hostname + // (e.g., db.example.com:1234). 'mysql.host' => 'localhost', // -- Email ----------------------------------------------------------------- // diff --git a/scripts/sql/upgrade_schema.php b/scripts/sql/upgrade_schema.php index 104dc6b027..f7a718f575 100755 --- a/scripts/sql/upgrade_schema.php +++ b/scripts/sql/upgrade_schema.php @@ -59,6 +59,7 @@ if (empty($options['f'])) { // Use always the version from the commandline if it is defined $next_version = isset($options['v']) ? (int)$options['v'] : null; +// TODO: Get this stuff from DatabaseConfigurationProvider? if ($options['u']) { $conn_user = $options['u']; $conn_pass = $options['p']; @@ -68,6 +69,17 @@ if ($options['u']) { } $conn_host = PhabricatorEnv::getEnvConfig('mysql.host'); +// Split out port information, since the command-line client requires a +// separate flag for the port. +$uri = new PhutilURI('mysql://'.$conn_host); +if ($uri->getPort()) { + $conn_port = $uri->getPort(); + $conn_bare_hostname = $uri->getDomain(); +} else { + $conn_port = null; + $conn_bare_hostname = $conn_host; +} + $conn = new AphrontMySQLDatabaseConnection( array( 'user' => $conn_user, @@ -118,11 +130,17 @@ END; $short_name = basename($patch['path']); print "Applying patch {$short_name}...\n"; + if ($conn_port) { + $port = '--port='.(int)$conn_port; + } else { + $port = null; + } + list($stdout, $stderr) = execx( - "mysql --user=%s --password=%s --host=%s < %s", + "mysql --user=%s --password=%s --host=%s {$port} < %s", $conn_user, $conn_pass, - $conn_host, + $conn_bare_hostname, $patch['path']); if ($stderr) {