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).
@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++
-
@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++
@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. -
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.
-
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.
@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>
-
@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.@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? -
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.
-
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.
@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
-
@JonB already wrote what to do:
@JonB said in QT is not able to connect to MySQL.:type export QT_DEBUG_PLUGINS=1
-
@JonB already wrote what to do:
@JonB said in QT is not able to connect to MySQL.:type export QT_DEBUG_PLUGINS=1
@SGaist said in QT is not able to connect to MySQL.:
@JonB already wrote what to do:
@JonB said in QT is not able to connect to MySQL.:type export QT_DEBUG_PLUGINS=1
The thing is that I don't know how to run it from the terminal, I do not understand the process, and I know this forum is not for C++, my bad :(
-
This has nothing to do with C++ in this case, it's the Linux
export
command.The instruction is literally: Type
export QT_DEBUG_PLUGINS=1
into your terminal. There's nothing more to it. -
This has nothing to do with C++ in this case, it's the Linux
export
command.The instruction is literally: Type
export QT_DEBUG_PLUGINS=1
into your terminal. There's nothing more to it.@SGaist said in QT is not able to connect to MySQL.:
This has nothing to do with C++ in this case, it's the Linux
export
command.The instruction is literally: Type
export QT_DEBUG_PLUGINS=1
into your terminal. There's nothing more to it.Alrighty!
As soon as I open the terminal I type that’s but it shows no output. Should I open the terminal on the folder where my project is? -
@SGaist said in QT is not able to connect to MySQL.:
This has nothing to do with C++ in this case, it's the Linux
export
command.The instruction is literally: Type
export QT_DEBUG_PLUGINS=1
into your terminal. There's nothing more to it.Alrighty!
As soon as I open the terminal I type that’s but it shows no output. Should I open the terminal on the folder where my project is?@Jesus-Ocegueda said in QT is not able to connect to MySQL.:
As soon as I open the terminal I type that’s but it shows no output
After typing this command you need to start the app (in same terminal):
export QT_DEBUG_PLUGINS=1 ./my_app_exe
If you want to start from QtCreator then set QT_DEBUG_PLUGINS in Projects/Build & Run/Run/Run Environment".
-
@Jesus-Ocegueda said in QT is not able to connect to MySQL.:
As soon as I open the terminal I type that’s but it shows no output
After typing this command you need to start the app (in same terminal):
export QT_DEBUG_PLUGINS=1 ./my_app_exe
If you want to start from QtCreator then set QT_DEBUG_PLUGINS in Projects/Build & Run/Run/Run Environment".
@jsulm said in QT is not able to connect to MySQL.:
@Jesus-Ocegueda said in QT is not able to connect to MySQL.:
As soon as I open the terminal I type that’s but it shows no output
After typing this command you need to start the app (in same terminal):
export QT_DEBUG_PLUGINS=1 ./my_app_exe
If you want to start from QtCreator then set QT_DEBUG_PLUGINS in Projects/Build & Run/Run/Run Environment".
So instead of ./my_app_exe it will be ./qt?
-
@jsulm said in QT is not able to connect to MySQL.:
@Jesus-Ocegueda said in QT is not able to connect to MySQL.:
As soon as I open the terminal I type that’s but it shows no output
After typing this command you need to start the app (in same terminal):
export QT_DEBUG_PLUGINS=1 ./my_app_exe
If you want to start from QtCreator then set QT_DEBUG_PLUGINS in Projects/Build & Run/Run/Run Environment".
So instead of ./my_app_exe it will be ./qt?
@Jesus-Ocegueda said in QT is not able to connect to MySQL.:
So instead of ./my_app_exe it will be ./qt?
Instead of my_app_exe you use the name of your executable
-
@Jesus-Ocegueda said in QT is not able to connect to MySQL.:
So instead of ./my_app_exe it will be ./qt?
Instead of my_app_exe you use the name of your executable
@jsulm said in QT is not able to connect to MySQL.:
@Jesus-Ocegueda said in QT is not able to connect to MySQL.:
So instead of ./my_app_exe it will be ./qt?
Instead of my_app_exe you use the name of your executable
You mean my .pro file?
-
@jsulm said in QT is not able to connect to MySQL.:
@Jesus-Ocegueda said in QT is not able to connect to MySQL.:
So instead of ./my_app_exe it will be ./qt?
Instead of my_app_exe you use the name of your executable
You mean my .pro file?
You mean my .pro file?
No, the executable program which you build and run all the time.
-
You mean my .pro file?
No, the executable program which you build and run all the time.
@JonB said in QT is not able to connect to MySQL.:
You mean my .pro file?
No, the executable program which you build and run all the time.
Alrighty, that will be the mainwindow.cpp -
@JonB said in QT is not able to connect to MySQL.:
You mean my .pro file?
No, the executable program which you build and run all the time.
Alrighty, that will be the mainwindow.cpp@Jesus-Ocegueda said in QT is not able to connect to MySQL.:
Alrighty, that will be the mainwindow.cpp
I'm afraid not, that is a source code file! No use at all here....
Have you ever written source code for a compiled language like C++ before? To be fair, since you reference
phpmyadmin
, you may not have done. But then there is a big comprehension leap.Do you understand what is going on when you type some code into a C++ file in Qt Creator and press one the Build (or Run or Debug) buttons? You don't need to know all the details, but I do think you should read up on what "compilation" is all about, because it will help with other things.
-
@Jesus-Ocegueda said in QT is not able to connect to MySQL.:
Alrighty, that will be the mainwindow.cpp
I'm afraid not, that is a source code file! No use at all here....
Have you ever written source code for a compiled language like C++ before? To be fair, since you reference
phpmyadmin
, you may not have done. But then there is a big comprehension leap.Do you understand what is going on when you type some code into a C++ file in Qt Creator and press one the Build (or Run or Debug) buttons? You don't need to know all the details, but I do think you should read up on what "compilation" is all about, because it will help with other things.
@JonB said in QT is not able to connect to MySQL.:
@Jesus-Ocegueda said in QT is not able to connect to MySQL.:
Alrighty, that will be the mainwindow.cpp
I'm afraid not, that is a source code file! No use at all here....
Have you ever written source code for a compiled language like C++ before? To be fair, since you reference
phpmyadmin
, you may not have done. But then there is a big comprehension leap.Do you understand what is going on when you type some code into a C++ file in Qt Creator and press one the Build (or Run or Debug) buttons? You don't need to know all the details, but I do think you should read up on what "compilation" is all about, because it will help with other things.
I understand, thank you for the recommendation, @JonB
-
@JonB said in QT is not able to connect to MySQL.:
You mean my .pro file?
No, the executable program which you build and run all the time.
Alrighty, that will be the mainwindow.cpp@Jesus-Ocegueda
Look, forget about directly running the executable for now!From Qt Creator:
- Click Projects down the left-hand "toolbar".
- In the window which comes up, at the left, in the Build & Run section, under Desktop, click on the word Run.
- In the Run Settings filling the main area, find Run Environment.
- It presently says: Use Build Environment.
- Click the Details button to the right of that.
- You are presented with a window with a list of all the environment variables your program will execute with.
- Click the Add button.
- Add an environment variable whose name is
QT_DEBUG_PLUGINS
, and give it a value of1
. - Now run your program from within Creator.
- Look in the Application Output window, at the bottom. You should see lots of diagnostic information.
This is what people were asking you to do. Whether it will contain useful information for whatever your issue is I do not know.