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. Connect with MySQL Database MacOs Ventura 13.4
Forum Updated to NodeBB v4.3 + New Features

Connect with MySQL Database MacOs Ventura 13.4

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 3 Posters 2.0k Views 1 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.
  • SGaistS SGaist

    Hi,

    Where exactly do you get these errors ?
    It looks like you are trying to run several MySQL instance at the same time.

    B Offline
    B Offline
    BushyAxis793
    wrote on last edited by
    #4

    @SGaist To be honest before I installed Qt Creator I downloaded MySQL and Xampp. When I run both I can see my database via localhost / phpadmin. Now after added plugin to Qt Creator I can't connect with database via Qt app. I can see this error when I click "Initialize Database" button. I can't uninstall MySQL because I need it for my QMySQL Plugin. I think you are right. I have more than one instance. But the question is how to disable it?

    6a73f42f-2019-440a-b8e2-51dcbf4e436c-image.png https://ddgobkiprc33d.cloudfront.net/9539ae1d-8662-47cf-b3b3-6768074ee978.png

    SGaistS 1 Reply Last reply
    0
    • B BushyAxis793

      @SGaist To be honest before I installed Qt Creator I downloaded MySQL and Xampp. When I run both I can see my database via localhost / phpadmin. Now after added plugin to Qt Creator I can't connect with database via Qt app. I can see this error when I click "Initialize Database" button. I can't uninstall MySQL because I need it for my QMySQL Plugin. I think you are right. I have more than one instance. But the question is how to disable it?

      6a73f42f-2019-440a-b8e2-51dcbf4e436c-image.png https://ddgobkiprc33d.cloudfront.net/9539ae1d-8662-47cf-b3b3-6768074ee978.png

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #5

      One thing you are currently not doing is printing the QSqlDatabase error when the open call fails. That should give you a hint about what is going wrong.

      Doesn't the XAMPP stack provide MySQL ? Here might be the doubling.

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

      B 1 Reply Last reply
      1
      • SGaistS SGaist

        One thing you are currently not doing is printing the QSqlDatabase error when the open call fails. That should give you a hint about what is going wrong.

        Doesn't the XAMPP stack provide MySQL ? Here might be the doubling.

        B Offline
        B Offline
        BushyAxis793
        wrote on last edited by
        #6

        @SGaist I decided to uninstall XAMPP for a testing time. I added this line of code to my connections function:

        qDebug()<<db.lastError();
        

        And I got this

        QSqlError("1045", "QMYSQL: Unable to connect", "Access denied for user 'root'@'localhost' (using password: NO)")
        

        This is strange a bit...

        SGaistS 1 Reply Last reply
        0
        • B BushyAxis793

          @SGaist I decided to uninstall XAMPP for a testing time. I added this line of code to my connections function:

          qDebug()<<db.lastError();
          

          And I got this

          QSqlError("1045", "QMYSQL: Unable to connect", "Access denied for user 'root'@'localhost' (using password: NO)")
          

          This is strange a bit...

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #7

          Are you sure the root user is configured to be accessible on localhost ? I don't think the default configuration allows that.

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

          B 1 Reply Last reply
          1
          • SGaistS SGaist

            Are you sure the root user is configured to be accessible on localhost ? I don't think the default configuration allows that.

            B Offline
            B Offline
            BushyAxis793
            wrote on last edited by BushyAxis793
            #8

            @SGaist Ok. So I decided to fix this issue. I follow this solution for root:

            https://stackoverflow.com/questions/50177216/how-to-grant-all-privileges-to-root-user-in-mysql-8-0

            I input:

            mysql -u root -p
            

            Then Input password and the result is:

            Welcome to the MySQL monitor.  Commands end with ; or \g.
            Your MySQL connection id is 9
            Server version: 8.0.33 MySQL Community Server - GPL
            
            Copyright (c) 2000, 2023, Oracle and/or its affiliates.
            
            Oracle is a registered trademark of Oracle Corporation and/or its
            affiliates. Other names may be trademarks of their respective
            owners.
            
            Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
            

            Next I input:

            CREATE USER 'root'@'%' IDENTIFIED BY '11111111';
            

            Output:

            Query OK, 0 rows affected (0,01 sec)
            

            Then I input:

            GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
            

            Result:

            Query OK, 0 rows affected (0,02 sec)
            

            Finally I input:

            FLUSH PRIVILEGES;
            

            And the result:

            Query OK, 0 rows affected (0,00 sec)
            

            Next I run my Qt Creator project and the error still exists.

            QSqlError("1045", "QMYSQL: Unable to connect", "Access denied for user 'root'@'localhost' (using password: NO)")
            

            I also checked port 3306 via

            sudo lsof -i -P | grep LISTEN | grep :3306
            

            and I got :

            mysqld    28777          _mysql   18u  IPv6 0x8a0d66b153d9f2cf      0t0    TCP *:33060 (LISTEN)
            mysqld    28777          _mysql   20u  IPv6 0x8a0d66b153d9cacf      0t0    TCP *:3306 (LISTEN)
            
            SGaistS 1 Reply Last reply
            0
            • B BushyAxis793

              @SGaist Ok. So I decided to fix this issue. I follow this solution for root:

              https://stackoverflow.com/questions/50177216/how-to-grant-all-privileges-to-root-user-in-mysql-8-0

              I input:

              mysql -u root -p
              

              Then Input password and the result is:

              Welcome to the MySQL monitor.  Commands end with ; or \g.
              Your MySQL connection id is 9
              Server version: 8.0.33 MySQL Community Server - GPL
              
              Copyright (c) 2000, 2023, Oracle and/or its affiliates.
              
              Oracle is a registered trademark of Oracle Corporation and/or its
              affiliates. Other names may be trademarks of their respective
              owners.
              
              Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
              

              Next I input:

              CREATE USER 'root'@'%' IDENTIFIED BY '11111111';
              

              Output:

              Query OK, 0 rows affected (0,01 sec)
              

              Then I input:

              GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
              

              Result:

              Query OK, 0 rows affected (0,02 sec)
              

              Finally I input:

              FLUSH PRIVILEGES;
              

              And the result:

              Query OK, 0 rows affected (0,00 sec)
              

              Next I run my Qt Creator project and the error still exists.

              QSqlError("1045", "QMYSQL: Unable to connect", "Access denied for user 'root'@'localhost' (using password: NO)")
              

              I also checked port 3306 via

              sudo lsof -i -P | grep LISTEN | grep :3306
              

              and I got :

              mysqld    28777          _mysql   18u  IPv6 0x8a0d66b153d9f2cf      0t0    TCP *:33060 (LISTEN)
              mysqld    28777          _mysql   20u  IPv6 0x8a0d66b153d9cacf      0t0    TCP *:3306 (LISTEN)
              
              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #9

              @BushyAxis793 silly question but: did you use the correct password ?

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

              B 1 Reply Last reply
              2
              • SGaistS SGaist

                @BushyAxis793 silly question but: did you use the correct password ?

                B Offline
                B Offline
                BushyAxis793
                wrote on last edited by
                #10

                @SGaist I'm sure the password is correct. I set it during mysql installation process.

                JonBJ 1 Reply Last reply
                0
                • B BushyAxis793

                  @SGaist I'm sure the password is correct. I set it during mysql installation process.

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #11

                  @BushyAxis793
                  But have you changed your db.setPassword(""); to include it? The error message

                  Access denied for user 'root'@'localhost' (using password: NO)

                  implies you are not passing any password to logon as root.

                  B 1 Reply Last reply
                  2
                  • JonBJ JonB

                    @BushyAxis793
                    But have you changed your db.setPassword(""); to include it? The error message

                    Access denied for user 'root'@'localhost' (using password: NO)

                    implies you are not passing any password to logon as root.

                    B Offline
                    B Offline
                    BushyAxis793
                    wrote on last edited by
                    #12

                    @JonB Oh my God... I forgot about it! I was focusing on mysql privileges... I inputed password and logged in!

                    I'm too distracted :)

                    Anyway everything seems works perfect :)

                    Thanks for help @SGaist and @JonB !

                    SGaistS 1 Reply Last reply
                    0
                    • B BushyAxis793 has marked this topic as solved on
                    • B BushyAxis793

                      @JonB Oh my God... I forgot about it! I was focusing on mysql privileges... I inputed password and logged in!

                      I'm too distracted :)

                      Anyway everything seems works perfect :)

                      Thanks for help @SGaist and @JonB !

                      SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #13

                      @BushyAxis793 one last thing: making your root account available on any and all point of access of your MySQL server is a wrong idea. You should rather create a dedicated user that has access to a specific database for that purpose.

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

                      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