QSqlDatabase: QMYSQL driver not loaded
I am using Qt Creator 2.4.1 in windows . While connecting to the database ,I am getting the following error
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC
Following is the code snippet :
Code:
db.setHostName( "localhost" );
db.setDatabaseName( "testdb" );
db.setUserName( "root" );
db.setPassword( "password" );
if( !db.open() )
{
qDebug() << db.lastError();
qDebug() <<QSqlDatabase::drivers() ;
qFatal( "Failed to connect." );
}
qDebug( "Connected!" );
db.close();
Regards ,
Prachi
Re: QSqlDatabase: QMYSQL driver not loaded
The QMYSQL driver is not listed among the available drivers. You need to build it for your Qt and compiler. See the SQL Database Drivers docs