Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How Can I Connect To MySql from client Computer?(Connect to Remote MysqL)
Forum Updated to NodeBB v4.3 + New Features

How Can I Connect To MySql from client Computer?(Connect to Remote MysqL)

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 7.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alireza.shirazi
    wrote on last edited by
    #1

    hi,
    i want to connect to Mysql from another PC .
    Both of System have Fedora linux version 15.0.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jake007
      wrote on last edited by
      #2

      Did you take at look at examples?

      I think SQL Browser example has all required information that you need.


      Code is poetry

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alireza.shirazi
        wrote on last edited by
        #3

        thanks jake.
        but i mean that connect to mysql server from another client on another pc.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Jake007
          wrote on last edited by
          #4

          That's what that example does.
          Take a look at "QSqlDatabase":http://qt-project.org/doc/qt-4.8/QSqlDatabase.html class and "here":http://qt-project.org/doc/qt-4.8/sql-connecting.html

          But you probably have access to Google search engine as I have ;) .


          Code is poetry

          1 Reply Last reply
          0
          • A Offline
            A Offline
            alireza.shirazi
            wrote on last edited by
            #5

            ok you right.
            i wrote code but give me under error:
            can't connect to Mysql server on 'Server ip address' (113)
            thanks a lot

            1 Reply Last reply
            0
            • J Offline
              J Offline
              Jake007
              wrote on last edited by
              #6

              It's hard to suggest anything without code.
              But check username, password and port. Check if the port is open to ( telnet command for example).

              Here is a short example for establishing connection:
              @// db is QSqlDatabase
              db = QSqlDatabase::addDatabase(DB_DRIVER); // example QMYSQL, QSQLITE, ...
              db.setHostName("localhost"); // or IP
              db.setPort(3306); // Default port is 3306
              db.setUserName(dbUser); // example root
              db.setPassword(dbPassword);
              db.setDatabaseName(dbName);

              if(!db.open())
              QMessageBox::warning(this, "Error", "NO CONNECTION");@

              For connecting to mySQL database, you'll need to compile QMYSQL driver ( everything is written on already provided link, but again, it's "here":http://doc.qt.nokia.com/4.7-snapshot/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows).
              But just for testing connection, you can use QSQLITE. Should work. It did at least for me.


              Code is poetry

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on last edited by
                #7

                [quote author="alireza.shirazi" date="1331049139"]ok you right.
                i wrote code but give me under error:
                can't connect to Mysql server on 'Server ip address' (113)
                thanks a lot[/quote]

                Did you replace "Server ip address" with the actual address (hostname or IP address)?

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved