QSql can not connect to MySQL
Posted
by
haha
on Stack Overflow
See other posts from Stack Overflow
or by haha
Published on 2012-12-11T10:37:58Z
Indexed on
2012/12/11
11:03 UTC
Read the original article
Hit count: 173
mysql
I have this code
db.QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
//db.setHostName("127.0.0.1");
//db.setPort(3306);
db.setDatabaseName("final");
db.setUserName("ll");
db.setPassword("123456");
bool ok = db.open();
When I run it, I get the following error message
error code : Access denied for user 'root'@'localhost' (using password: NO) QMYSQL: Unable to connect
I'm not connecting to MySQL by root@localhost but *ll@localhost. Why do I get this error message? Where is the problem?
© Stack Overflow or respective owner