Results 1 to 6 of 6

Thread: Can't connect to MySQL server on '192.xxx.x.x' (111) QMYSQL: Unable to connect

  1. #1
    Join Date
    Jan 2014
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Can't connect to MySQL server on '192.xxx.x.x' (111) QMYSQL: Unable to connect

    I am trying to sync two databases using a local IP. Though I have the QMYSQL driver installed properly it still gives an error for connection failed.
    A main database is created on host computer and I'm trying to sync data from another computer to this database through a local network.
    Code on host computer:
    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL","Host");
    2. db.setHostName("HOSTIP");
    3. db.setDatabaseName("test");
    4. db.setUserName("root");
    5. db.setPassword("toor");
    To copy to clipboard, switch view to plain text mode 
    Code on other computer:
    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL","Other");
    2. db.setHostName("IP OF HOST");
    3. db.setDatabaseName("test");
    4. db.setUserName("root");
    5. db.setPassword("toor");
    To copy to clipboard, switch view to plain text mode 
    Any help is appreciated!!
    Last edited by shawshank; 26th January 2014 at 08:02.

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

    Default Re: Can't connect to MySQL server on '192.xxx.x.x' (111) QMYSQL: Unable to connect

    Are the Mysql servers configured to accept connections via IP (i.e. skip_networking not im my.cnf, bind-address not restricting)? Can you connect using those credentials with the Mysql command line tools (i.e. without Qt)?

  3. #3
    Join Date
    Jan 2014
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Can't connect to MySQL server on '192.xxx.x.x' (111) QMYSQL: Unable to connect

    I have never configured MySql with Qt. This is my first attempt. Could you tell me how to check if MySql servers are configured to accept connections via IP?

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,580
    Thanks
    13
    Thanked 1,584 Times in 1,513 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Can't connect to MySQL server on '192.xxx.x.x' (111) QMYSQL: Unable to connect

    Configuring the Mysql server has nothing to do with Qt. Try connecting from one of the machines using the tools supplied with mysql first:
    Qt Code:
    1. mysql -h 192.a.b.c -u root -p test
    To copy to clipboard, switch view to plain text mode 
    If that doesn't work then the problem also has nothing to do with Qt.

    The Mysql server configuration is in a file called my.cnf which may be in any number of locations (often /etc/mysql/my.cnf but YMMV). The two obvious options to check in that file are bind-address (should include 192.a.b.c) and skip-networking (should be absent/commented) in the "[mysqld]" group
    http://dev.mysql.com/doc/refman/5.6/...ion-files.html
    http://dev.mysql.com/doc/refman/5.6/...variables.html

  5. #5
    Join Date
    Jan 2014
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Can't connect to MySQL server on '192.xxx.x.x' (111) QMYSQL: Unable to connect

    Thanks for your reply!!
    I tried using the MySql tools to connect with the database on the other IP. But it still gives the same error on the terminal.
    Could you please tell me how to configure the MySql server? I can't understand how to change the values of bind-address and skip-networking.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,580
    Thanks
    13
    Thanked 1,584 Times in 1,513 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Can't connect to MySQL server on '192.xxx.x.x' (111) QMYSQL: Unable to connect

    You change the values with a text editor after stopping the MySql server. Find the section labelled "[mysqld]", comment out the skip-networking line if present, change the bind-address line to:
    Qt Code:
    1. [mysqld]
    2. ...
    3.  
    4. # Commented out
    5. # skip-networking
    6.  
    7. # Wide open, listens on all interfaces
    8. bind-address 0.0.0.0
    9. # Or more restricted, listen only on specified interface
    10. bind-address 192.168.1.1
    To copy to clipboard, switch view to plain text mode 
    Beyond that I suggest you go back to MySql sources. This has nothing to do with Qt.

  7. The following user says thank you to ChrisW67 for this useful post:

    shawshank (30th January 2014)

Similar Threads

  1. Replies: 15
    Last Post: 11th March 2014, 02:54
  2. Connect to the MYSQL server successful but can't see any data
    By stereoMatching in forum Qt Programming
    Replies: 1
    Last Post: 9th January 2014, 05:06
  3. Replies: 2
    Last Post: 16th April 2012, 14:42
  4. Replies: 1
    Last Post: 7th April 2012, 07:05
  5. Mysql unknown database, QMYSQL unable to connect
    By lixo1 in forum Qt Programming
    Replies: 3
    Last Post: 14th July 2010, 22:39

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.