Database not being created
Hi all I have been trying for hours now to get a MySQL database to work in my project. Only problem is I am unable to create the database. I don't get any errors anything, nothing seems to happen. Everything compiles fine but no databases are created. Qt tells me that I have all the database drivers i need...
I have: ("QSQLITE", "QMYSQL3", "QMYSQL", "QODBC3", "QODBC")
The code that I'm using to try and create my database is:
Code:
db.addDatabase("QMYSQL");
db.setDatabaseName("test");
if(!db.open()){
message.information(this, "Error", "Database not opened");
}
What am I doing wrong? This is all beginning to annoy me now!!
Thanks for your time and trouble. Any help would be much appreciated :)
Re: Database not being created
Two things:
- You need to provide the Mysql plugin with a host name, user name, and password. From the docs:
Code:
db.setHostName("bigblue");
db.setDatabaseName("flightdb");
db.setUserName("acarlson");
db.setPassword("1uTbSbAs");
bool ok = db.open();
- The plugin will not create the Mysql database if it does not exist.