Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to connect to mysql
Forum Update on Monday, May 27th 2025

How to connect to mysql

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 249 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mocha Shakea Khan
    wrote on last edited by
    #1

    I tried to search for solutions but so far none have worked. I'm using windows 10.

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("127.0.0.1");
    db.setUserName("root");
    db.setPassword("");
    db.setDatabaseName("slmp");

    if (db.open())
        ui->db_label->setText("Connected...");
    else {
        ui->db_label->setText("Failed to connect");
    }
    

    When i try to run this code it fails to connect because mysql driver isn't loaded. I looked up how to fix this and it says to download mysql connector. I downloaded the c++ 8.0.15 win 32 connector. 1st I added the vs14 file through the add library function but that failed. Then I pasted the libeay32.dll and the other dll files that comes with it in the mscv2015_64 and that failed. I also tried pasting the dll files in mscv2017, mscv2017_64, mingw73_64 all lead to failures.

    KillerSmathK 1 Reply Last reply
    0
    • M Mocha Shakea Khan

      I tried to search for solutions but so far none have worked. I'm using windows 10.

      QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
      db.setHostName("127.0.0.1");
      db.setUserName("root");
      db.setPassword("");
      db.setDatabaseName("slmp");

      if (db.open())
          ui->db_label->setText("Connected...");
      else {
          ui->db_label->setText("Failed to connect");
      }
      

      When i try to run this code it fails to connect because mysql driver isn't loaded. I looked up how to fix this and it says to download mysql connector. I downloaded the c++ 8.0.15 win 32 connector. 1st I added the vs14 file through the add library function but that failed. Then I pasted the libeay32.dll and the other dll files that comes with it in the mscv2015_64 and that failed. I also tried pasting the dll files in mscv2017, mscv2017_64, mingw73_64 all lead to failures.

      KillerSmathK Offline
      KillerSmathK Offline
      KillerSmath
      wrote on last edited by
      #2

      Hello @Mocha-Shakea-Khan and welcome to Qt Forum.

      Have you tried this fixed post ?
      https://forum.qt.io/topic/40672/how-to-create-the-plugin-of-mysql-for-qt

      @Computer Science Student - Brazil
      Web Developer and Researcher
      “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

      1 Reply Last reply
      4

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved