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. QT is not able to connect to MySQL.
Forum Updated to NodeBB v4.3 + New Features

QT is not able to connect to MySQL.

Scheduled Pinned Locked Moved Unsolved General and Desktop
36 Posts 6 Posters 7.1k 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 Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi and welcome to devnet,

    Which version of Qt are you using ?
    On which OS ?
    Which version of MySQL ?
    How did you install Qt ?

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

    J 1 Reply Last reply
    0
    • SGaistS SGaist

      Hi and welcome to devnet,

      Which version of Qt are you using ?
      On which OS ?
      Which version of MySQL ?
      How did you install Qt ?

      J Offline
      J Offline
      Jesus Ocegueda
      wrote on last edited by
      #3

      @SGaist
      My QT version is 5.12.8, I'm using Ubuntu20.04. MySQL is Ver 8.0.23. QT installed by downloading the file form its official web.

      1 Reply Last reply
      0
      • J Jesus Ocegueda

        Hello everyone, this is my first time in the forum. I'm trying work with a database in phpmyadmin but it seems I'm unable to do so. I'm a beginner and I know I ignore lots of things but I'm willing to learn.

        This is the code in mainwindow.cpp:

        #include "mainwindow.h"
        #include "ui_mainwindow.h"

        #include<QTimer>
        #include<QDateTime>
        #include<QDate>
        #include<QDebug>
        #include<QTime>

        #include<QSqlDatabase>
        #include<QtSql>
        #include<QSqlQuery>
        #include<QtNetwork>
        #include<QSqlError>

        QSqlDatabase baseDatos;

        void MainWindow::cronometro(){
        //Obtener tiempo real
        QDateTime fechaActual = QDateTime::currentDateTime();
        tiempoEpoch=fechaActual.toTime_t();
        //long int tiempoUnix =fechaActual.toTime_t();
        //qDebug() << "Time: " <<tiempoUnix;
        ui->label_8->setText(fechaActual.toString());
        QTime tiempoActual = QTime::currentTime();
        //qDebug() << "Tiempo actual: " << tiempoActual;
        int horas = tiempoActual.hour();
        int minutos = tiempoActual.minute();
        int segundos = tiempoActual.second();
        ui->lcdNumber->display(horas);
        ui->lcdNumber_2->display(minutos);
        ui->lcdNumber_3->display(segundos);
        }

        MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::MainWindow)
        {
        ui->setupUi(this);
        QTimer *temporizador = new QTimer(this);
        connect(temporizador, SIGNAL(timeout()), this, SLOT(cronometro()));
        temporizador->start(1000);
        baseDatos = QSqlDatabase::addDatabase("QMYSQL");
        baseDatos.setHostName("localhost");
        baseDatos.setPort(3306);
        baseDatos.setDatabaseName("tarea");
        baseDatos.setUserName("admin51");
        baseDatos.setPassword("hola1234");

        if(baseDatos.open()){
            qDebug() << "Data base is open";
        }
        else{
            qDebug() << "Data base is NOT open";
        }
        

        }

        MainWindow::~MainWindow()
        {
        delete ui;
        }

        void MainWindow::on_pushButton_clicked()
        {
        codigo = ui->lineEdit->text();
        evento = "Ent";

        if(baseDatos.open()){
            //Insertar 4 columnas
            QString comandoMYSQL = "INSERT INTO ejemplo3_checador_tiempo(fecha,codigo,evento,imagen) VALUES(?,?,?,?)";
            QSqlQuery comando;
            comando.prepare(comandoMYSQL);
            comando.addBindValue(codigo);
            comando.addBindValue(evento);
            QVariant valorlong = QVariant::fromValue(tiempoEpoch);
            //qDebug() << "Tiempo: " << valorLong;
            comando.addBindValue(valorlong);
            comando.addBindValue(imagen);
            if(comando.exec()){
             qDebug() << "El dato se inserto correctamente";
            }
            else{
            qDebug() << "Error";
           }
        }
        

        }

        void MainWindow::on_pushButton_2_clicked()
        {
        codigo = ui->lineEdit->text();
        evento = "Sal";

        if(baseDatos.open()){
            //Insertar 4 columnas
            QString comandoMYSQL = "INSERT INTO ejemplo3_checador_tiempo(fecha,codigo,evento,imagen) VALUES(?,?,?,?)";
            QSqlQuery comando;
            comando.prepare(comandoMYSQL);
            comando.addBindValue(codigo);
            comando.addBindValue(evento);
            QVariant valorlong = QVariant::fromValue(tiempoEpoch);
            //qDebug() << "Tiempo: " << valorLong;
            comando.addBindValue(valorlong);
            comando.addBindValue(imagen);
            if(comando.exec()){
                 qDebug() << "El dato se inserto correctamente";
            }
            else{
                 qDebug() << "Error";
            }
        }
        

        }

        I will appreciate your support.

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

        @Jesus-Ocegueda said in QT is not able to connect to MySQL.:

        but it seems I'm unable to do so

        What exactly happens?

        Set QT_DEBUG_PLUGINS environment variable before starting your app and post its output (https://doc.qt.io/qt-5/debug.html).

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

        J 2 Replies Last reply
        1
        • J Jesus Ocegueda

          Hello everyone, this is my first time in the forum. I'm trying work with a database in phpmyadmin but it seems I'm unable to do so. I'm a beginner and I know I ignore lots of things but I'm willing to learn.

          This is the code in mainwindow.cpp:

          #include "mainwindow.h"
          #include "ui_mainwindow.h"

          #include<QTimer>
          #include<QDateTime>
          #include<QDate>
          #include<QDebug>
          #include<QTime>

          #include<QSqlDatabase>
          #include<QtSql>
          #include<QSqlQuery>
          #include<QtNetwork>
          #include<QSqlError>

          QSqlDatabase baseDatos;

          void MainWindow::cronometro(){
          //Obtener tiempo real
          QDateTime fechaActual = QDateTime::currentDateTime();
          tiempoEpoch=fechaActual.toTime_t();
          //long int tiempoUnix =fechaActual.toTime_t();
          //qDebug() << "Time: " <<tiempoUnix;
          ui->label_8->setText(fechaActual.toString());
          QTime tiempoActual = QTime::currentTime();
          //qDebug() << "Tiempo actual: " << tiempoActual;
          int horas = tiempoActual.hour();
          int minutos = tiempoActual.minute();
          int segundos = tiempoActual.second();
          ui->lcdNumber->display(horas);
          ui->lcdNumber_2->display(minutos);
          ui->lcdNumber_3->display(segundos);
          }

          MainWindow::MainWindow(QWidget *parent)
          : QMainWindow(parent)
          , ui(new Ui::MainWindow)
          {
          ui->setupUi(this);
          QTimer *temporizador = new QTimer(this);
          connect(temporizador, SIGNAL(timeout()), this, SLOT(cronometro()));
          temporizador->start(1000);
          baseDatos = QSqlDatabase::addDatabase("QMYSQL");
          baseDatos.setHostName("localhost");
          baseDatos.setPort(3306);
          baseDatos.setDatabaseName("tarea");
          baseDatos.setUserName("admin51");
          baseDatos.setPassword("hola1234");

          if(baseDatos.open()){
              qDebug() << "Data base is open";
          }
          else{
              qDebug() << "Data base is NOT open";
          }
          

          }

          MainWindow::~MainWindow()
          {
          delete ui;
          }

          void MainWindow::on_pushButton_clicked()
          {
          codigo = ui->lineEdit->text();
          evento = "Ent";

          if(baseDatos.open()){
              //Insertar 4 columnas
              QString comandoMYSQL = "INSERT INTO ejemplo3_checador_tiempo(fecha,codigo,evento,imagen) VALUES(?,?,?,?)";
              QSqlQuery comando;
              comando.prepare(comandoMYSQL);
              comando.addBindValue(codigo);
              comando.addBindValue(evento);
              QVariant valorlong = QVariant::fromValue(tiempoEpoch);
              //qDebug() << "Tiempo: " << valorLong;
              comando.addBindValue(valorlong);
              comando.addBindValue(imagen);
              if(comando.exec()){
               qDebug() << "El dato se inserto correctamente";
              }
              else{
              qDebug() << "Error";
             }
          }
          

          }

          void MainWindow::on_pushButton_2_clicked()
          {
          codigo = ui->lineEdit->text();
          evento = "Sal";

          if(baseDatos.open()){
              //Insertar 4 columnas
              QString comandoMYSQL = "INSERT INTO ejemplo3_checador_tiempo(fecha,codigo,evento,imagen) VALUES(?,?,?,?)";
              QSqlQuery comando;
              comando.prepare(comandoMYSQL);
              comando.addBindValue(codigo);
              comando.addBindValue(evento);
              QVariant valorlong = QVariant::fromValue(tiempoEpoch);
              //qDebug() << "Tiempo: " << valorLong;
              comando.addBindValue(valorlong);
              comando.addBindValue(imagen);
              if(comando.exec()){
                   qDebug() << "El dato se inserto correctamente";
              }
              else{
                   qDebug() << "Error";
              }
          }
          

          }

          I will appreciate your support.

          KroMignonK Offline
          KroMignonK Offline
          KroMignon
          wrote on last edited by KroMignon
          #5

          @Jesus-Ocegueda said in QT is not able to connect to MySQL.:

          if(baseDatos.open()){
              qDebug() << "Data base is open";
          }
          else{
              qDebug() << "Data base is NOT open";
          }
          

          I would suggest you to change this to:

          if(baseDatos.open()){
              qDebug() << "Data base is open";
          }
          else{
              qDebug() << "Data base is NOT open:" << baseDatos.lastError().text();
          }
          

          How did you install Qt-Kit on your PC, with MaintenanceTool or with the packet manager of your Linux distribution?
          AFAIK, starting with Qt 5.12.x, the MySQL plugin is only distributed with MaintenanceTool as sources and must be build by yourself, because of Oracle/MySQL licencing changes.

          => https://doc.qt.io/qt-5.12/sql-driver.html#how-to-build-the-qmysql-plugin-on-unix-and-macos

          It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

          J 2 Replies Last reply
          2
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            Since you are using a pretty recent Linux distribution, you might want to consider using the Qt version provided by it rather than building the plugin yourself (not that it is something hard though).

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

            J 1 Reply Last reply
            1
            • jsulmJ jsulm

              @Jesus-Ocegueda said in QT is not able to connect to MySQL.:

              but it seems I'm unable to do so

              What exactly happens?

              Set QT_DEBUG_PLUGINS environment variable before starting your app and post its output (https://doc.qt.io/qt-5/debug.html).

              J Offline
              J Offline
              Jesus Ocegueda
              wrote on last edited by
              #7
              This post is deleted!
              1 Reply Last reply
              0
              • KroMignonK KroMignon

                @Jesus-Ocegueda said in QT is not able to connect to MySQL.:

                if(baseDatos.open()){
                    qDebug() << "Data base is open";
                }
                else{
                    qDebug() << "Data base is NOT open";
                }
                

                I would suggest you to change this to:

                if(baseDatos.open()){
                    qDebug() << "Data base is open";
                }
                else{
                    qDebug() << "Data base is NOT open:" << baseDatos.lastError().text();
                }
                

                How did you install Qt-Kit on your PC, with MaintenanceTool or with the packet manager of your Linux distribution?
                AFAIK, starting with Qt 5.12.x, the MySQL plugin is only distributed with MaintenanceTool as sources and must be build by yourself, because of Oracle/MySQL licencing changes.

                => https://doc.qt.io/qt-5.12/sql-driver.html#how-to-build-the-qmysql-plugin-on-unix-and-macos

                J Offline
                J Offline
                Jesus Ocegueda
                wrote on last edited by
                #8
                This post is deleted!
                1 Reply Last reply
                0
                • KroMignonK KroMignon

                  @Jesus-Ocegueda said in QT is not able to connect to MySQL.:

                  if(baseDatos.open()){
                      qDebug() << "Data base is open";
                  }
                  else{
                      qDebug() << "Data base is NOT open";
                  }
                  

                  I would suggest you to change this to:

                  if(baseDatos.open()){
                      qDebug() << "Data base is open";
                  }
                  else{
                      qDebug() << "Data base is NOT open:" << baseDatos.lastError().text();
                  }
                  

                  How did you install Qt-Kit on your PC, with MaintenanceTool or with the packet manager of your Linux distribution?
                  AFAIK, starting with Qt 5.12.x, the MySQL plugin is only distributed with MaintenanceTool as sources and must be build by yourself, because of Oracle/MySQL licencing changes.

                  => https://doc.qt.io/qt-5.12/sql-driver.html#how-to-build-the-qmysql-plugin-on-unix-and-macos

                  J Offline
                  J Offline
                  Jesus Ocegueda
                  wrote on last edited by
                  #9

                  @KroMignon said in QT is not able to connect to MySQL.:

                  @Jesus-Ocegueda said in QT is not able to connect to MySQL.:

                  if(baseDatos.open()){
                      qDebug() << "Data base is open";
                  }
                  else{
                      qDebug() << "Data base is NOT open";
                  }
                  

                  I would suggest you to change this to:

                  if(baseDatos.open()){
                      qDebug() << "Data base is open";
                  }
                  else{
                      qDebug() << "Data base is NOT open:" << baseDatos.lastError().text();
                  }
                  

                  How did you install Qt-Kit on your PC, with MaintenanceTool or with the packet manager of your Linux distribution?
                  AFAIK, starting with Qt 5.12.x, the MySQL plugin is only distributed with MaintenanceTool as sources and must be build by yourself, because of Oracle/MySQL licencing changes.

                  => https://doc.qt.io/qt-5.12/sql-driver.html#how-to-build-the-qmysql-plugin-on-unix-and-macos

                  This is what I got: "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) QMYSQL: Unable to connect"

                  KroMignonK 1 Reply Last reply
                  0
                  • Christian EhrlicherC Online
                    Christian EhrlicherC Online
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    @Jesus-Ocegueda said in QT is not able to connect to MySQL.:

                    "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) QMYSQL: Unable to connect"

                    So you should make sure your MySQL server is running (on the given port).

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    1 Reply Last reply
                    3
                    • J Jesus Ocegueda

                      @KroMignon said in QT is not able to connect to MySQL.:

                      @Jesus-Ocegueda said in QT is not able to connect to MySQL.:

                      if(baseDatos.open()){
                          qDebug() << "Data base is open";
                      }
                      else{
                          qDebug() << "Data base is NOT open";
                      }
                      

                      I would suggest you to change this to:

                      if(baseDatos.open()){
                          qDebug() << "Data base is open";
                      }
                      else{
                          qDebug() << "Data base is NOT open:" << baseDatos.lastError().text();
                      }
                      

                      How did you install Qt-Kit on your PC, with MaintenanceTool or with the packet manager of your Linux distribution?
                      AFAIK, starting with Qt 5.12.x, the MySQL plugin is only distributed with MaintenanceTool as sources and must be build by yourself, because of Oracle/MySQL licencing changes.

                      => https://doc.qt.io/qt-5.12/sql-driver.html#how-to-build-the-qmysql-plugin-on-unix-and-macos

                      This is what I got: "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) QMYSQL: Unable to connect"

                      KroMignonK Offline
                      KroMignonK Offline
                      KroMignon
                      wrote on last edited by KroMignon
                      #11

                      @Jesus-Ocegueda said in QT is not able to connect to MySQL.:

                      This is what I got: "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) QMYSQL: Unable to connect"

                      It looks like that the MySQL plugin is there.
                      Are you sure that you setup the right connection options?
                      You could test it with the console client:

                      mysql --host=localhost --port=3306 --user=admin51 --password=hola1234 tarea
                      

                      cf. https://dev.mysql.com/doc/refman/8.0/en/connecting.html

                      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                      J 1 Reply Last reply
                      1
                      • SGaistS SGaist

                        Since you are using a pretty recent Linux distribution, you might want to consider using the Qt version provided by it rather than building the plugin yourself (not that it is something hard though).

                        J Offline
                        J Offline
                        Jesus Ocegueda
                        wrote on last edited by Jesus Ocegueda
                        #12

                        @SGaist said in QT is not able to connect to MySQL.:

                        Since you are using a pretty recent Linux distribution, you might want to consider using the Qt version provided by it rather than building the plugin yourself (not that it is something hard though).

                        You recommend uninstall QT and install it from the terminal?
                        LIke this: https://www.osradar.com/install-qtcreator-on-ubuntu-20-04-18-04/

                        1 Reply Last reply
                        0
                        • KroMignonK KroMignon

                          @Jesus-Ocegueda said in QT is not able to connect to MySQL.:

                          This is what I got: "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) QMYSQL: Unable to connect"

                          It looks like that the MySQL plugin is there.
                          Are you sure that you setup the right connection options?
                          You could test it with the console client:

                          mysql --host=localhost --port=3306 --user=admin51 --password=hola1234 tarea
                          

                          cf. https://dev.mysql.com/doc/refman/8.0/en/connecting.html

                          J Offline
                          J Offline
                          Jesus Ocegueda
                          wrote on last edited by
                          #13

                          @KroMignon said in QT is not able to connect to MySQL.:

                          mysql --host=localhost --port=3306 --user=admin51 --password=hola1234 tarea

                          This is the output I got after running the command line your gave me:

                          jesus@jesus-Inspiron-5559:~$ mysql --host=localhost --port=3306 --user=admin51 --password=hola1234 tarea
                          mysql: [Warning] Using a password on the command line interface can be insecure.
                          Reading table information for completion of table and column names
                          You can turn off this feature to get a quicker startup with -A

                          Welcome to the MySQL monitor. Commands end with ; or \g.
                          Your MySQL connection id is 8
                          Server version: 8.0.23-0ubuntu0.20.04.1 (Ubuntu)

                          Copyright (c) 2000, 2021, 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.

                          mysql>

                          1 Reply Last reply
                          0
                          • jsulmJ jsulm

                            @Jesus-Ocegueda said in QT is not able to connect to MySQL.:

                            but it seems I'm unable to do so

                            What exactly happens?

                            Set QT_DEBUG_PLUGINS environment variable before starting your app and post its output (https://doc.qt.io/qt-5/debug.html).

                            J Offline
                            J Offline
                            Jesus Ocegueda
                            wrote on last edited by
                            #14

                            @jsulm said in QT is not able to connect to MySQL.:

                            @Jesus-Ocegueda said in QT is not able to connect to MySQL.:

                            but it seems I'm unable to do so

                            What exactly happens?

                            Set QT_DEBUG_PLUGINS environment variable before starting your app and post its output (https://doc.qt.io/qt-5/debug.html).

                            How do I set that? Would you mind give me an example?

                            I'm guessing that I only need to place it right after my libraries on my mainwindow.cpp file. Is that correct?
                            LIke: QT_DEBUG_PLUGINS;

                            I'm not sure because this is my first time with C++

                            JonBJ 1 Reply Last reply
                            0
                            • J Jesus Ocegueda

                              @jsulm said in QT is not able to connect to MySQL.:

                              @Jesus-Ocegueda said in QT is not able to connect to MySQL.:

                              but it seems I'm unable to do so

                              What exactly happens?

                              Set QT_DEBUG_PLUGINS environment variable before starting your app and post its output (https://doc.qt.io/qt-5/debug.html).

                              How do I set that? Would you mind give me an example?

                              I'm guessing that I only need to place it right after my libraries on my mainwindow.cpp file. Is that correct?
                              LIke: QT_DEBUG_PLUGINS;

                              I'm not sure because this is my first time with C++

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

                              @Jesus-Ocegueda
                              I'm guessing you run your program from within Qt Creator? In which case you need to set it as a runtime environment variable for when your program is executed.

                              If you know how to run your executable from a terminal you need to type export QT_DEBUG_PLUGINS=1 there.

                              J 1 Reply Last reply
                              1
                              • Christian EhrlicherC Online
                                Christian EhrlicherC Online
                                Christian Ehrlicher
                                Lifetime Qt Champion
                                wrote on last edited by
                                #16

                                Since the mysql plugin is properly loaded there is no problem with Qt at all. Please read e.g. here: https://www.dailyrazor.com/blog/cant-connect-to-local-mysql-server-through-socket/ - the first idea would be to use 127.0.0.1 as suggested there so no local socket but tcp/ip is used.

                                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                Visit the Qt Academy at https://academy.qt.io/catalog

                                J 1 Reply Last reply
                                2
                                • Christian EhrlicherC Christian Ehrlicher

                                  Since the mysql plugin is properly loaded there is no problem with Qt at all. Please read e.g. here: https://www.dailyrazor.com/blog/cant-connect-to-local-mysql-server-through-socket/ - the first idea would be to use 127.0.0.1 as suggested there so no local socket but tcp/ip is used.

                                  J Offline
                                  J Offline
                                  Jesus Ocegueda
                                  wrote on last edited by Jesus Ocegueda
                                  #17

                                  @Christian-Ehrlicher said in QT is not able to connect to MySQL.:

                                  Since the mysql plugin is properly loaded there is no problem with Qt at all. Please read e.g. here: https://www.dailyrazor.com/blog/cant-connect-to-local-mysql-server-through-socket/ - the first idea would be to use 127.0.0.1 as suggested there so no local socket but tcp/ip is used.

                                  I follow the article and doing the first instruction I got this:

                                  jesus@jesus-Inspiron-5559:~$ mysqladmin -u root -p status
                                  Enter password:
                                  mysqladmin: connect to server at 'localhost' failed
                                  error: 'Access denied for user 'root'@'localhost''

                                  After I try the option u provided I got this in QT:

                                  Data base is NOT open "SSL connection error: unknown error number QMYSQL: Unable to connect"

                                  I found intriguing that 'root'@__'localhost''__ it has another ' after host. Should I consider that too?

                                  I also run sudo mysql and here are the users I have:

                                  jesus@jesus-Inspiron-5559:~$ sudo mysql
                                  [sudo] password for jesus:
                                  Welcome to the MySQL monitor. Commands end with ; or \g.
                                  Your MySQL connection id is 13
                                  Server version: 8.0.23-0ubuntu0.20.04.1 (Ubuntu)

                                  Copyright (c) 2000, 2021, 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.

                                  mysql> SELECT user, authentication_string,plugin,host FROM msql.user;
                                  ERROR 1049 (42000): Unknown database 'msql'
                                  mysql> SELECT user, authentication_string,plugin,host FROM mysql.user;
                                  +------------------+------------------------------------------------------------------------+-----------------------+-----------+
                                  | user | authentication_string | plugin | host |
                                  +------------------+------------------------------------------------------------------------+-----------------------+-----------+
                                  | admin51 | $A$005$9T
                                  T^&)o@TW^Q-h_&oT.MY9ehrMXFyNzv8k33JesTDZXuHjqUMWeSdvI14f22 | caching_sha2_password | % |
                                  | debian-sys-maint | $A$005$(t[Bxr/[VJ_%KIDDL2c8KVbWsqR4cm7eSWTfZtbj1Y7HHnMl3IrkUhJr5 | caching_sha2_password | localhost |
                                  | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | localhost |
                                  | mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | localhost |
                                  | mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | localhost |
                                  | phpmyadmin | $A$005$:;]J;=H]l9 }E|QYK8HLtTg7fPJ7r3DC.syBTVait3ZiLHSfUaGEKiKkF0 | caching_sha2_password | localhost |
                                  | root | | auth_socket | localhost |
                                  +------------------+------------------------------------------------------------------------+-----------------------+-----------+
                                  7 rows in set (0.01 sec)

                                  mysql>

                                  1 Reply Last reply
                                  0
                                  • JonBJ JonB

                                    @Jesus-Ocegueda
                                    I'm guessing you run your program from within Qt Creator? In which case you need to set it as a runtime environment variable for when your program is executed.

                                    If you know how to run your executable from a terminal you need to type export QT_DEBUG_PLUGINS=1 there.

                                    J Offline
                                    J Offline
                                    Jesus Ocegueda
                                    wrote on last edited by
                                    #18

                                    @JonB said in QT is not able to connect to MySQL.:

                                    @Jesus-Ocegueda
                                    I'm guessing you run your program from within Qt Creator? In which case you need to set it as a runtime environment variable for when your program is executed.

                                    If you know how to run your executable from a terminal you need to type export QT_DEBUG_PLUGINS=1 there.

                                    How do I run it from terminal?
                                    Should I just open a terminal on the folder my .pro file is?

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

                                      Just do the export, it will be valid for the terminal session until you unset it or close the terminal.

                                      Then go to the folder where your application is and execute it.

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

                                      J 1 Reply Last reply
                                      0
                                      • SGaistS SGaist

                                        Just do the export, it will be valid for the terminal session until you unset it or close the terminal.

                                        Then go to the folder where your application is and execute it.

                                        J Offline
                                        J Offline
                                        Jesus Ocegueda
                                        wrote on last edited by
                                        #20

                                        @SGaist said in QT is not able to connect to MySQL.:

                                        Just do the export, it will be valid for the terminal session until you unset it or close the terminal.

                                        Then go to the folder where your application is and execute it.

                                        I bet this is easy but I don't get how to proceed when you say export, will you mind explain that or how to look it up that on google to search how to do that

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

                                          @JonB already wrote what to do:
                                          @JonB said in QT is not able to connect to MySQL.:

                                          type export QT_DEBUG_PLUGINS=1

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

                                          J 1 Reply Last reply
                                          0

                                          • Login

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