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. MySQL Connection failed,but i entered correct info of server
Forum Updated to NodeBB v4.3 + New Features

MySQL Connection failed,but i entered correct info of server

Scheduled Pinned Locked Moved Unsolved General and Desktop
msyqlqt6.0.1c++serverdatabase
16 Posts 4 Posters 2.3k Views 2 Watching
  • 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.
  • E ELEMENTICY

    Hello again,
    i cant connect my sql server i dont know why.Theres no error,it just when i did
    if (db.open()) it will go to else which is not able to connect mysql server
    this is my code

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
        db.setHostName("localhost");
        db.setDatabaseName("pos");
        db.setUserName("root");
        db.setPort(3306);
        db.setPassword("");
        if (db.open())
        {
    

    all info i entered is correct
    but i dont know why it doesnt work at all.Please help,
    and yea,i downloaded libmysql.dll and libmysqld.dll and place it to C:\Qt\6.0.1\mingw81_64\bin
    Please help mee,thx

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #2

    @ELEMENTICY said in MySQL Connection failed,but i entered correct info of server:

    Theres no error,

    How do you know? I don't see any error handling in your code. Print https://doc.qt.io/qt-5/qsqldatabase.html#lastError in the else block

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    E 1 Reply Last reply
    1
    • E ELEMENTICY

      Hello again,
      i cant connect my sql server i dont know why.Theres no error,it just when i did
      if (db.open()) it will go to else which is not able to connect mysql server
      this is my code

      QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
          db.setHostName("localhost");
          db.setDatabaseName("pos");
          db.setUserName("root");
          db.setPort(3306);
          db.setPassword("");
          if (db.open())
          {
      

      all info i entered is correct
      but i dont know why it doesnt work at all.Please help,
      and yea,i downloaded libmysql.dll and libmysqld.dll and place it to C:\Qt\6.0.1\mingw81_64\bin
      Please help mee,thx

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #3

      @ELEMENTICY said in MySQL Connection failed,but i entered correct info of server:

      and yea,i downloaded libmysql.dll and libmysqld.dll

      What compiler were used to build those and what compiler do you use?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      E 1 Reply Last reply
      0
      • jsulmJ jsulm

        @ELEMENTICY said in MySQL Connection failed,but i entered correct info of server:

        and yea,i downloaded libmysql.dll and libmysqld.dll

        What compiler were used to build those and what compiler do you use?

        E Offline
        E Offline
        ELEMENTICY
        wrote on last edited by
        #4

        @jsulm youtube lemme put that dll inside.I follow all instruction,but it doesnt work ;-;

        jsulmJ 1 Reply Last reply
        0
        • E ELEMENTICY

          @jsulm youtube lemme put that dll inside.I follow all instruction,but it doesnt work ;-;

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #5

          @ELEMENTICY Did you read my first reply?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • jsulmJ jsulm

            @ELEMENTICY said in MySQL Connection failed,but i entered correct info of server:

            Theres no error,

            How do you know? I don't see any error handling in your code. Print https://doc.qt.io/qt-5/qsqldatabase.html#lastError in the else block

            E Offline
            E Offline
            ELEMENTICY
            wrote on last edited by
            #6

            @jsulm
            i do,but qt forum dont let me send another reply within 600 second

            i mean theres no error o code,not on database.
            But i tried use qDebug() << db.lastError();
            and this is the error:
            QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QODBC QPSQL QSqlError("", "Driver not loaded", "Driver not loaded")

            jsulmJ 1 Reply Last reply
            0
            • E ELEMENTICY

              @jsulm
              i do,but qt forum dont let me send another reply within 600 second

              i mean theres no error o code,not on database.
              But i tried use qDebug() << db.lastError();
              and this is the error:
              QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QODBC QPSQL QSqlError("", "Driver not loaded", "Driver not loaded")

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #7

              @ELEMENTICY QMYSQL is not listed as available. I guess you will have to build it by yourself. https://doc.qt.io/qt-5/sql-driver.html
              But before that do this: set QT_DEBUG_PLUGINS environment variable to 1 before starting your app and then post its output here.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              E 1 Reply Last reply
              1
              • jsulmJ jsulm

                @ELEMENTICY QMYSQL is not listed as available. I guess you will have to build it by yourself. https://doc.qt.io/qt-5/sql-driver.html
                But before that do this: set QT_DEBUG_PLUGINS environment variable to 1 before starting your app and then post its output here.

                E Offline
                E Offline
                ELEMENTICY
                wrote on last edited by
                #8

                @jsulm Hmm,but i saw QMYSQL on
                https://doc.qt.io/qt-5/sql-driver.html#qmysql
                Maybe because of other reason?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  Hi,

                  The plugin is currently not pre-built anymore as Oracle changed their licensing with regards to MySQL so you'll have to build it yourself.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  E 1 Reply Last reply
                  3
                  • SGaistS SGaist

                    Hi,

                    The plugin is currently not pre-built anymore as Oracle changed their licensing with regards to MySQL so you'll have to build it yourself.

                    E Offline
                    E Offline
                    ELEMENTICY
                    wrote on last edited by
                    #10

                    @SGaist do you have any link for tutorial to build it?
                    thanks!

                    jsulmJ 1 Reply Last reply
                    0
                    • E ELEMENTICY

                      @SGaist do you have any link for tutorial to build it?
                      thanks!

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      @ELEMENTICY https://doc.qt.io/qt-5/sql-driver.html#qmysql

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      E 1 Reply Last reply
                      1
                      • jsulmJ jsulm

                        @ELEMENTICY https://doc.qt.io/qt-5/sql-driver.html#qmysql

                        E Offline
                        E Offline
                        ELEMENTICY
                        wrote on last edited by
                        #12

                        @jsulm thanks for replying,but i dont understand.Can you teach me or explain it to me please?Thank you

                        JKSHJ 1 Reply Last reply
                        0
                        • E ELEMENTICY

                          @jsulm thanks for replying,but i dont understand.Can you teach me or explain it to me please?Thank you

                          JKSHJ Offline
                          JKSHJ Offline
                          JKSH
                          Moderators
                          wrote on last edited by
                          #13

                          @ELEMENTICY said in MySQL Connection failed,but i entered correct info of server:

                          Can you teach me or explain it to me please?Thank you

                          Go to @jsulm's link again and scroll down. There is a section called "How to Build the QMYSQL Plugin on Windows" -- it contains instructions on how to build the DLL.

                          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                          E 2 Replies Last reply
                          2
                          • JKSHJ JKSH

                            @ELEMENTICY said in MySQL Connection failed,but i entered correct info of server:

                            Can you teach me or explain it to me please?Thank you

                            Go to @jsulm's link again and scroll down. There is a section called "How to Build the QMYSQL Plugin on Windows" -- it contains instructions on how to build the DLL.

                            E Offline
                            E Offline
                            ELEMENTICY
                            wrote on last edited by
                            #14

                            @JKSH yea,i just found it after i said that.
                            Can you help vote any of my question? So i have repulation or else i have to wait 600 second everytime

                            https://doc.qt.io/qt-5/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows

                            here is it

                            1 Reply Last reply
                            0
                            • JKSHJ JKSH

                              @ELEMENTICY said in MySQL Connection failed,but i entered correct info of server:

                              Can you teach me or explain it to me please?Thank you

                              Go to @jsulm's link again and scroll down. There is a section called "How to Build the QMYSQL Plugin on Windows" -- it contains instructions on how to build the DLL.

                              E Offline
                              E Offline
                              ELEMENTICY
                              wrote on last edited by
                              #15

                              @JKSH Hello again,
                              I tried it,it doesnt work.
                              Can you help again xD

                              JKSHJ 1 Reply Last reply
                              0
                              • E ELEMENTICY

                                @JKSH Hello again,
                                I tried it,it doesnt work.
                                Can you help again xD

                                JKSHJ Offline
                                JKSHJ Offline
                                JKSH
                                Moderators
                                wrote on last edited by
                                #16

                                @ELEMENTICY said in MySQL Connection failed,but i entered correct info of server:

                                I tried it,it doesnt work.
                                Can you help again xD

                                You need to provide details of what you tried and what errors you got. Without the details, we can't help you.

                                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                1 Reply Last reply
                                1

                                • Login

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