当前位置:网站首页>The reasons why QT fails to connect to the database and common solutions
The reasons why QT fails to connect to the database and common solutions
2022-07-04 01:45:00 【CAccept】
use qDebug() << db.lastError().text(); Look at the cause of the error
① First, check your database name , user name , Host name , password , Are these port numbers set correctly
For example, if I write the user name wrong, the following error will appear
"Access denied for user 'rot'@'localhost' (using password: YES) QMYSQL: Unable to connect"
The database connection code is as follows
db.setDatabaseName("qtqq");// Database name ( Keep consistent with your settings )
db.setHostName("localhost");// Host name
db.setUserName("root");// user name
db.setPassword("sqhxxxx");// Password and us Mysql Your account and password are the same
db.setPort(3306);// Set the port number

② Look at your Navicat Is it open and connected ( I often forget )
③ If the problem is the lack of drivers, you have to add some files
The problem is displayed as :QMYSQL driver not loaded
resolvent :
mysql Of the installation file lib In the catalog libmysql.dll and libmysqld.dll Copied to the Qt5.5 Medium mingw Of bin Under the document .
If I know the reasons for other types of connection failures later, I will add , Now make do with it
边栏推荐
- In the process of seeking human intelligent AI, meta bet on self supervised learning
- C import Xls data method summary I (upload files and create Workbooks)
- Pyinstaller packaging py script warning:lib not found and other related issues
- Luogu p1309 Swiss wheel
- Conditional statements of shell programming
- I don't know why it can't run in the project and how to change it
- 0 basic learning C language - nixie tube dynamic scanning display
- Stringutils and collectionutils
- Summary of JWT related knowledge
- Portable two-way radio equipment - current market situation and future development trend
猜你喜欢

Long article review: entropy, free energy, symmetry and dynamics in the brain

C import Xls data method summary II (save the uploaded file to the DataTable instance object)

IPv6 experiment

Applet graduation project is based on wechat classroom laboratory reservation applet graduation project opening report function reference

Applet graduation design is based on wechat course appointment registration. Applet graduation design opening report function reference

LeetCode 168. Detailed explanation of Excel list name

Three layer switching ①
![Jerry's synchronous weather information to equipment [chapter]](/img/a9/e09bbf62161ea8ba60b0fce3fb5f89.jpg)
Jerry's synchronous weather information to equipment [chapter]

How to use AHAS to ensure the stability of Web services?

Huawei rip and BFD linkage
随机推荐
Gnupg website
Solution to the problem that jsp language cannot be recognized in idea
The latest analysis of hoisting machinery command in 2022 and free examination questions of hoisting machinery command
Basic editing specifications and variables of shell script
Winter vacation daily question -- a single element in an ordered array
Ka! Why does the seat belt suddenly fail to pull? After reading these pictures, I can't stop wearing them
Pyrethroid pesticide intermediates - market status and future development trend
CLP information - how does the digital transformation of credit business change from star to finger?
Containerization technology stack
MySQL - use of aggregate functions and group by groups
Pratique technique | analyse et solution des défaillances en ligne (Partie 1)
Reading notes - learn to write: what is writing?
IPv6 experiment
String hash, find the string hash value after deleting any character, double hash
Flutter local database sqflite
MySQL introduction - functions (various function statistics, exercises, details, tables)
Three layer switching ①
QML add gradient animation during state transition
ThinkPHP uses redis to update database tables
Maximum likelihood method, likelihood function and log likelihood function