MySql could not load the driver



  • I have an application that runs perfectly on my computer, even from a deployment folder that i use to run windeployqt. My problem is that when i take the application to the test compiuter it does not connect to the database. I have modify the function to connect to the database so it show on a text widget the message:
    Does the test computer needs some parts from MySql for this to run? Thanks for the help.

    void DatabaseConnection::on_conenct_clicked()
    {
    db->setHostName(ui->hostname->text());
    db->setDatabaseName("grcr");
    db->setUserName(ui->user->text());
    db->setPassword(ui->passwd->text());
    if(db->open()==true)
    {
    workData->databaseAddress=ui->hostname->text();
    workData->dbUserName=ui->user->text();
    workData->dbUserPswd=ui->passwd->text();
    ui->status->setText("Connected");
    }
    else
    {
    ui->Data->append(db->connectionName());
    ui->Data->append(db->connectOptions());
    ui->Data->append(db->hostName());
    ui->Data->append(db->lastError().text());
    ui->Data->append(QString::number(db->port()));
    db->close();
    ui->status->setText("Not Connected");
    }

    }

    P.S. i did looked for other qtsqlmysql.dll drivers on the test computer but could not find any. Just in case the application was grabbing something from somewhere else.


  • I am also facing this situation, though drivers are available, but it is not loading. possible reason could mysql libraries are not linked in the .pro file.



  • Well, i tried all kind of different things. I tried to use "dependency walker" to see if i could see what going on to no avail. I downloaded all kind of packages and connectors from MySql website, i even installed mysql workbench and connected to the database. But my application refused to work. Keep telling me that could not load the driver. I'm working on a program that i hope I'm going to sell, when i do i will subscribe to QT customer service but that is too expensive right now, so no finding a solution that can be easily implemented on a customer desktop is not an option. My next step is to compile the program statically, i'm in the process of creating the static compiler for QT. Will let you what happens.



  • In your program's folder there should be folder /sqldrivers/ in which qsqlmysql.dll file should be placed.



  • Maybe you can try to copy libmysql.dll from database installation folder (I don't remember exact place) but for me it helped.



  • @wojtusm Then you need link to that file while compiling the project. Default MySQL built into Qt uses qsqlmysql.dll as a plugin and nothing more should be required (apart from Qt5Sql.dll in main program's folder).



  • Thanks for the advice. I used windeployqt and the tool created all necessary folder and copy all necessary dlls. I did tried, and probably still there, libmysql.dll, i put a copy on the directory where the exe is located. one copy in the sqldrivers directory, but it would not load the driver.
    I have spend more than 12 hours trying to solve this. I really hope that static building will solve the problem or else is more that a month of work wasted as i'm afraid to release a program that will not work on a customer computer.



  • @Dan3460 said in MySql could not load the driver:

    I did tried, and probably still there, libmysql.dll, i put a copy on the directory where the exe is located.

    Can you please make sure that qsqlmysql.dll file is located in %programdir%/sqldrivers/ folder?

    I assume you compiled the program in release mode. For debug mode file name would be qsqlmysqld.dll.



  • @artwaw Thanks for the answer. Yes i used the windeployqt to create the release folder and yes it was compiled using the release mode. I check the sqldrivers folder and the qsqlmysql.dll is there.



  • My apologies to everyone, it was my stupidity. I was looking at the libmysql.dll, the one that i have been playing with had a time stamp of 8/13/2015, that is the one that i have been using to make the distribution folder. I look on my system and there is a libmysql.dll that is dated 7/13/2017 and it is much smaller. So grabbed that dll and put it on the other system and it works perfectly. My guess is that the older dll is a 64bit, while im compiling everything on 32bit. Again please accept my apologies.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.