Pergunta

I have a MediaWiki installation on a shared host server. It's at version 1.19.1 and I'm trying to update to 1.22.2. The documentation indicates that a one-step update should be OK for this.

I've done this several times for past updates successfully, and am following previous notes. I set up a new directory with 1.22.2 in it, copied LocalSettings.php and /images/ files from the working live directory to the new one. LocalSettings.php has entries for $wgDBuser, $wgDBpassword, $wgDBadminuser and $wgDBadminpassword all defined.

I have command line access to the server, and tried to run the update process in WikiNew, by

php maintenance/update.php

but it responds:

DB connection error: Unknown MySQL server host 'localhost:/tmp/mysql5.sock' (34) (localhost:/tmp/mysql5.sock)

If I do the same in WikiLive it works. Of course it does not do any actual update as I'm updating 1.19.1 to 1.19.1, but the usual type of messages appear but with indications that changes are not required, and it purges caches. LiviWiki, 1.19, still works.

So the same data for the connection string exists in both copies of LocalSettings.php, both copies of maintenance/update.php are accessing the same MySQL database, but one accepts the connection string and the other doesn't.

Has something changed between 1.19 and 1.22? I've looked for 'Configuration changes' in the release notes for 1.20, 1.21, and 1.22, but see no instruction to make any change.

Please help!

Thank you.

Foi útil?

Solução

For the record, the answer was to change the DB host from

$wgDBserver = "localhost:/tmp/mysql5.sock"

to just

$wgDBserver = "localhost"

The original string should have worked, but there is a bug in MediaWiki 1.19.2, described here:

https://bugzilla.wikimedia.org/show_bug.cgi?id=58153

"The new mysqli adapter in 1.22.0 does not properly implement non-standard MySQL ports."

Outras dicas

I ran into a similar problem with the difference that the connect string for the MySQL server I use was of the form of host:port:socket as in localhost:3306:/var/lib/mysock.

I am attempting to install mediawiki-1.22.6 and the initial database check was failing. Using only localhost did not work for me since the MySQL installation I am using required both a port number and a socket.

I ended up making the following changes to the mediawiki-1.22.6 php scripts in order to allow for the parsing of a connect string of the form of host:port:socket.

WARNING: These changes are specific to my site and environment and the parsing function changes probably will not work properly with other strings for instance if the port number is not specified as in localhost:/var/lib/mysock.

Here are the specific changes I made to complete installation.

In file IP.php in the relative directory of Includes there is a function public static function splitHostAndPort( $both ) which takes the connect string and parses it breaking it up into the necessary parts for the real_connect() call in function protected function mysqlConnect( $realServer ) located in file DatabaseMysqli.php in the relative folder includes/db.

in the function splitHostAndPort() I modified the function to the following:

public static function splitHostAndPort( $both ) {
    if ( substr( $both, 0, 1 ) === '[' ) {
        if ( preg_match( '/^\[(' . RE_IPV6_ADD . ')\](?::(?P<port>\d+))?$/', $both, $m ) ) {
            if ( isset( $m['port'] ) ) {
                return array( $m[1], intval( $m['port'] ) );
            } else {
                return array( $m[1], false );
            }
        } else {
            // Square bracket found but no IPv6
            return false;
        }
    }
    $numColons = substr_count( $both, ':' );
    if ( $numColons >= 2 ) {
        // Is it a bare IPv6 address?
        if ( preg_match( '/^' . RE_IPV6_ADD . '$/', $both ) ) {
            return array( $both, false );
        } else {
            // Not valid IPv6, but too many colons for anything else
            // may be of the form localhost:port:socket
            // return false;
        }
    }
    if ( $numColons >= 1 ) {
        // Host:port:socket?
        $bits = explode( ':', $both );
        if ( preg_match( '/^\d+/', $bits[1] ) ) {
            if ($numColons > 1) {
                return array( $bits[0], intval( $bits[1] ), $bits[2] );
            } else {
                return array( $bits[0], intval( $bits[1] ) );
            }
        } else {
            // Not a valid port
            return false;
        }
    }
    // Plain hostname
    return array( $both, false );
}

Next I modified the mysqlConnect() function so that it performed a check to see if both port and socket are specified as follows:

// Other than mysql_connect, mysqli_real_connect expects an explicit port
// parameter. So we need to parse the port out of $realServer
$socketname = $port = null;
$hostAndPort = IP::splitHostAndPort( $realServer );
if ( $hostAndPort ) {
    $realServer = $hostAndPort[0];
    if ( $hostAndPort[1] ) {
        $port = $hostAndPort[1];
    }
    if ( $hostAndPort[2] ) {
        $socketname = $hostAndPort[2];
    }
}

and then modified the call to real_connect() to also specify a socket

if ( $mysqli->real_connect( $realServer, $this->mUser,
    $this->mPassword, $this->mDBname, $port, $socketname, $connFlags ) )
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top