[英]Qt remote database with MySql?
What is the best way to add remote MySql database connectivity. 添加远程MySql数据库连接的最佳方法是什么。
I have attempted using the QODBC driver with no luck, I believe another issue may be that this is a shared server but believe I have the right settings according to my host . 我试图使用QODBC驱动程序没有运气,我相信另一个问题可能是这是一个共享服务器,但我相信我根据我的主机设置了正确的设置 。
Here is my current attempt: 这是我目前的尝试:
bool CardSQL::connectSQL(void){
db = QSqlDatabase::addDatabase("QODBC");
db.setHostName("173.254.28.127");// Tried www.themindspot.com & ip with http:// and https://
db.setPort(3306);
db.setDatabaseName("dbName");
db.setUserName("dbUser");
db.setPassword("dbPass");
bool ok = db.open();
return ok;
}
I check 'ok' in a if statement and it keeps coming back failed. 我在if语句中检查'ok'并且它一直在返回失败。
My guess is that your MySQL server on your justhost.com shared host is not running on a public network interface, and is only accessible via localhost (meaning you have to be running your apps locally on the server to connect). 我的猜测是你的justhost.com共享主机上的MySQL服务器没有在公共网络接口上运行,只能通过localhost访问(这意味着你必须在服务器上本地运行你的应用程序才能连接)。 If there is an option to do it, its probably not currently doing it. 如果有一个选项可以做,它可能目前没有这样做。
Some cpanel configurations have a "Remote Database Access Hosts" option which lets you specify specific external domains that are allowed to connect to your MySQL database. 某些cpanel配置具有“远程数据库访问主机”选项,允许您指定允许连接到MySQL数据库的特定外部域。
Also, for mysql you would probably be using the QMYSQL
database driver. 另外,对于mysql,您可能正在使用QMYSQL
数据库驱动程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.