1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-29 16:08:22 +01:00

Document how to set a MySQL port

Summary:
This already pretty much works, document it explicitly.

Test Plan:
Moved my MySQL server over to port 3307.

Reviewed By: aran
Reviewers: jungejason, aran
CC: aran
Differential Revision: 411
This commit is contained in:
epriestley 2011-06-08 10:10:11 -07:00
parent 112346ee61
commit 49d6854f95
2 changed files with 23 additions and 3 deletions

View file

@ -75,7 +75,9 @@ return array(
// The password to use when connecting to MySQL. // The password to use when connecting to MySQL.
'mysql.pass' => '', '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', 'mysql.host' => 'localhost',
// -- Email ----------------------------------------------------------------- // // -- Email ----------------------------------------------------------------- //

View file

@ -59,6 +59,7 @@ if (empty($options['f'])) {
// Use always the version from the commandline if it is defined // Use always the version from the commandline if it is defined
$next_version = isset($options['v']) ? (int)$options['v'] : null; $next_version = isset($options['v']) ? (int)$options['v'] : null;
// TODO: Get this stuff from DatabaseConfigurationProvider?
if ($options['u']) { if ($options['u']) {
$conn_user = $options['u']; $conn_user = $options['u'];
$conn_pass = $options['p']; $conn_pass = $options['p'];
@ -68,6 +69,17 @@ if ($options['u']) {
} }
$conn_host = PhabricatorEnv::getEnvConfig('mysql.host'); $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( $conn = new AphrontMySQLDatabaseConnection(
array( array(
'user' => $conn_user, 'user' => $conn_user,
@ -118,11 +130,17 @@ END;
$short_name = basename($patch['path']); $short_name = basename($patch['path']);
print "Applying patch {$short_name}...\n"; print "Applying patch {$short_name}...\n";
if ($conn_port) {
$port = '--port='.(int)$conn_port;
} else {
$port = null;
}
list($stdout, $stderr) = execx( list($stdout, $stderr) = execx(
"mysql --user=%s --password=%s --host=%s < %s", "mysql --user=%s --password=%s --host=%s {$port} < %s",
$conn_user, $conn_user,
$conn_pass, $conn_pass,
$conn_host, $conn_bare_hostname,
$patch['path']); $patch['path']);
if ($stderr) { if ($stderr) {