Load MySQL Database, can't connect to host. [SOLVED]
I am trying to connect to a database using the following code:
#define q2c(string) string.toStdString()
int main(int countArg, char **listArg)
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
std::cout << "Connected " << q2c(db.hostName()) << std::endl;
std::cout << "Error :(" << std::endl << q2c(db.lastError().text()) << std::endl;
Here the output at execution:
Can't connect to MySQL server on 'pivoine' (111) QMYSQL: Unable to connect
I don't know what to try, thanks for your help.
what about the port? Is the server running on a different port (default port for MYSQL server is 3306)? If so you need to specifiy it. But it wouldn't be bad to add it anyway to rid out this cause.
Can the application load the database plugin?
Try to list the available database drivers with QSqlDatabase::drivers
In fact it was a stupid mistake of mane related to the hostame for mysql.
So now it is fine.