Virtual Spatial Data and MySQL client

Frank Warmerdam fwarmerdam at GMAIL.COM
Thu Jul 21 12:56:20 EDT 2005


On 7/21/05, Bart van den Eijnden <BEN at syncera-itsolutions.nl> wrote:
> Hi list,
> 
> I can't connect to a MySQL database using the MySQL client in OGR. I am using MySQL client 4.1 on a 4.1 localhost database. It works fine through ODBC.
> 
> It looks like GDAL/OGR is trying to log in with a different user than I specify, the Windows user logged on to the computer, how come?
> 
> I get the following:
> 
> D:\ms4w\apps\stragisweb\htdocs\sites\mdwh\data>ogrinfo bedrijven_mysqlclient.ovf
> 
> ERROR 4: Update access not supported for VRT datasources.
> Warning 1: 'database=westholland' in MYSQL datasource definition not recognised
> and ignored.
> ERROR 1: MySQL connect failed for: user=root,password=psv9570,port=3306,database
> =westholland
> Access denied for user 'BEN'@'localhost' (using password: YES)
> FAILURE:

Bart,

Sorry, I don't know why that isn't working.  As I read the code, it
should have passed in root as the userid.   In the module:

  gdal/ogr/ogrsf_frmts/mysql/ogrmysqldatasource.cpp 

there is a call like:

    if( hConn
        && mysql_real_connect( hConn, 
                               oHost.length() ? oHost.c_str() : NULL,
                               oUser.length() ? oUser.c_str() : NULL,
                               oPassword.length() ? oPassword.c_str() : NULL,
                               oDB.length() ? oDB.c_str() : NULL,
                               nPort, NULL, 0 ) == NULL )
    {
        CPLError( CE_Failure, CPLE_AppDefined,
                  "MySQL connect failed for: %s\n%s", 
                  pszNewName + 6, mysql_error( hConn ) );
        mysql_close( hConn );
        hConn = NULL;
    }

My suggestion is that you add a printf() to report the actual arguments
being passed to this functions for debugging purposes. 

eg. 
  printf( "user=%s, password=%d\n", oUser.c_str(), oPassword.c_str() );

If the user reported by this is root then it is something funky deep
inside the mysql API.  If it is "BEN" or an empty string then we know
that something is going wrong in the parsing logic for the datasource
name (which you can follow up with me). 

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the mapserver-users mailing list