Results 1 to 3 of 3

Thread: [SOLVED] can't connect to remote mysql server

  1. #1
    Join Date
    Dec 2011
    Posts
    18
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default [SOLVED] can't connect to remote mysql server

    Hello! I've built the Qt Driver for Mysql and it works fine, when I log into localhost mysql is working and ready but whenever I try to access a remote mysql over the network (not local) it gives me an error, even though I have the credentials to connect (I can test it via mysql console) here's a code snippet about my connection information, if you have some time plz look it up



    Qt Code:
    1. Database::Database()
    2. {
    3. db = QSqlDatabase::addDatabase("QMYSQL");
    4. db.setHostName("66.23.54.32"); // fake ip ;)
    5. db.setPort(3306);
    6. db.setDatabaseName("stephan");
    7. db.setUserName("root");
    8. db.setPassword("root");
    9. db.open();
    10.  
    11.  
    12. }
    13.  
    14. void Database::openConnection(){
    15.  
    16. if (!db.open())
    17. { QMessageBox::critical(0,QObject::tr("Database Error"),
    18. db.lastError().text());
    19. }
    20.  
    21. else qDebug()<<"SUCCESS";
    22.  
    23. }
    24.  
    25. QSqlDatabase Database::getDb(){
    26.  
    27. return db;
    28. }
    To copy to clipboard, switch view to plain text mode 




    much appreciated
    Last edited by Pluvius; 16th April 2012 at 13:49. Reason: updated contents

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: can't connect to remote mysql server

    So what does QSqlDatabase::lastError() tell you?

  3. #3
    Join Date
    Dec 2011
    Posts
    18
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: can't connect to remote mysql server

    Hello again!
    turns out it had something to do with NAT settings + the server was down when I tried to access it through Qt

    Thank you for replying

Similar Threads

  1. Replies: 3
    Last Post: 8th March 2011, 07:57
  2. IR remote Connect Mouse Qt embedded ?
    By Thành Viên Mới in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 17th February 2011, 06:41
  3. Questions about connect to remote database
    By stmk in forum Qt Programming
    Replies: 3
    Last Post: 11th November 2010, 10:02
  4. QFtp: downloading a whole folder from a remote server.
    By balazsbela in forum Qt Programming
    Replies: 5
    Last Post: 5th August 2007, 09:34
  5. Acces to a remote mysql server
    By Alienxs in forum Qt Programming
    Replies: 2
    Last Post: 19th August 2006, 03:10

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.