QSql can not connect to MySQL
- by haha
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?