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

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.0k 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.
  • E ELEMENTICY
    9 Mar 2021, 05:39

    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

    J Offline
    J Offline
    jsulm
    Lifetime Qt Champion
    wrote on 9 Mar 2021, 06:15 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 9 Mar 2021, 06:31
    0
    • J jsulm
      9 Mar 2021, 06:15

      @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 9 Mar 2021, 06:31 last edited by
      #4

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

      J 1 Reply Last reply 9 Mar 2021, 06:32
      0
      • E ELEMENTICY
        9 Mar 2021, 06:31

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

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 9 Mar 2021, 06:32 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
        • J jsulm
          9 Mar 2021, 06:14

          @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 9 Mar 2021, 06:42 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")

          J 1 Reply Last reply 9 Mar 2021, 06:46
          0
          • E ELEMENTICY
            9 Mar 2021, 06:42

            @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")

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 9 Mar 2021, 06:46 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 9 Mar 2021, 12:15
            1
            • J jsulm
              9 Mar 2021, 06:46

              @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 9 Mar 2021, 12:15 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
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 9 Mar 2021, 12:36 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 10 Mar 2021, 01:26
                3
                • S SGaist
                  9 Mar 2021, 12:36

                  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 10 Mar 2021, 01:26 last edited by
                  #10

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

                  J 1 Reply Last reply 10 Mar 2021, 05:17
                  0
                  • E ELEMENTICY
                    10 Mar 2021, 01:26

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

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 10 Mar 2021, 05:17 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 11 Mar 2021, 01:59
                    1
                    • J jsulm
                      10 Mar 2021, 05:17

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

                      E Offline
                      E Offline
                      ELEMENTICY
                      wrote on 11 Mar 2021, 01:59 last edited by
                      #12

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

                      J 1 Reply Last reply 11 Mar 2021, 02:10
                      0
                      • E ELEMENTICY
                        11 Mar 2021, 01:59

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

                        J Offline
                        J Offline
                        JKSH
                        Moderators
                        wrote on 11 Mar 2021, 02:10 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 11 Mar 2021, 03:01
                        2
                        • J JKSH
                          11 Mar 2021, 02:10

                          @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 11 Mar 2021, 03:01 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
                          • J JKSH
                            11 Mar 2021, 02:10

                            @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 11 Mar 2021, 04:10 last edited by
                            #15

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

                            J 1 Reply Last reply 11 Mar 2021, 04:21
                            0
                            • E ELEMENTICY
                              11 Mar 2021, 04:10

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

                              J Offline
                              J Offline
                              JKSH
                              Moderators
                              wrote on 11 Mar 2021, 04:21 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

                              12/16

                              11 Mar 2021, 01:59

                              • Login

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