March 4, 2012

alireza.shirazi alireza.shir..
Lab Rat
6 posts

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

 

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

6 replies

March 4, 2012

Jake007 Jake007
Robot Herder
248 posts

Did you take at look at examples?

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

 Signature 

——————————————-
Code is poetry

March 5, 2012

alireza.shirazi alireza.shir..
Lab Rat
6 posts

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

March 5, 2012

Jake007 Jake007
Robot Herder
248 posts

That’s what that example does.
Take a look at QSqlDatabase [qt-project.org] class and here [qt-project.org]

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

 Signature 

——————————————-
Code is poetry

March 6, 2012

alireza.shirazi alireza.shir..
Lab Rat
6 posts

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

March 7, 2012

Jake007 Jake007
Robot Herder
248 posts

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:

  1. // db is QSqlDatabase
  2.  db = QSqlDatabase::addDatabase(DB_DRIVER); // example QMYSQL, QSQLITE, ...
  3.  db.setHostName("localhost"); // or IP
  4.  db.setPort(3306); // Default port is 3306
  5.  db.setUserName(dbUser); // example root
  6.  db.setPassword(dbPassword);
  7.  db.setDatabaseName(dbName);
  8.  
  9.  if(!db.open())
  10.   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 [doc.qt.nokia.com]).
But just for testing connection, you can use QSQLITE. Should work. It did at least for me.

 Signature 

——————————————-
Code is poetry

March 8, 2012

Volker Volker
Robot Herder
5428 posts
alireza.shirazi wrote:
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

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

 
  ‹‹ Resizing a widget’s non-Qt child window after resize      How can i open persistent editor which itself closed ››

You must log in to post a reply. Not a member yet? Register here!