Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, August 2007
(mysql5-devel,macosX,eclipse europa CDT,Qt4.3.1) unable to connect to mySQL


Message 1 in thread

Hello,

I ran this program:

#include <QtSql>
#include <QApplication>
#include <QtGui>


int main(int argc,char* argv[]){
    QApplication app(argc,argv);
    QSqlDatabase db;
    QString chaine;
        for (int i=0;i < db.drivers().count();i++){
            chaine += db.drivers().value(i);
            chaine += "\n\r";
        }       
    QMessageBox::information(0,"connexion à la base",chaine);
   
    db=QSqlDatabase::addDatabase("QMYSQL");
   
    db.setHostName("localhost");
    db.setDatabaseName("mysql");
    db.setUserName("root");
    db.setPassword("123543");
    if (!db.open())
        QMessageBox::critical(0,"Database error",db.lastError().text());
    else
        QMessageBox::information(0,"connexion à la base","OK");
   
    return app.exec();
  
}

and I have the following issue:
-first message: mySQL is displayed: the driver is recognized
-second message: I have the error:

can't connect to local MySQL server through socket 
'/opt/local/var/run/mysql5-devel/mysqld.sock' (2)

QMYSQL: unable to connect.

I specify that I have installed (before Qt) mysql5 from the site 
www.mysql.com. Is there a conflict between the two installation (the 
second one is an installation via macports of the port "mysql5-devel", 
followed by the compilation of the mysql plugin, the one which is 
recognized by the program above)?


regards,

lolveley.








Message 2 in thread

I would like to add that I had a look to this file (mysqld.sock), mysql 
said me its socket was "/tmp/mysqld.sock" and I found no folder 
"/opt/local/var/run/mysql5-devel/", so I created this directory and I 
copied mysqld.sock inside it, but the error remains.

Last thing, reading the archives of this mailing-list, I saw that it was 
possible to modify the file qsql_mysql.cpp and inside it to modify the 
variable unix_socket from NULL to /tmp/mysqld.sock (after that, a new 
compilation of Qt is needed).
I tried, but - is it the change of version - I did not found the 
variable unix_socket (one time but at line 1000+ and without any NULL 
around it).

You know all the story!

lolveley.

lolveley a écrit :
> Hello,
>
> I ran this program:
>
> #include <QtSql>
> #include <QApplication>
> #include <QtGui>
>
>
> int main(int argc,char* argv[]){
>     QApplication app(argc,argv);
>     QSqlDatabase db;
>     QString chaine;
>         for (int i=0;i < db.drivers().count();i++){
>             chaine += db.drivers().value(i);
>             chaine += "\n\r";
>         }       
>     QMessageBox::information(0,"connexion à la base",chaine);
>    
>     db=QSqlDatabase::addDatabase("QMYSQL");
>    
>     db.setHostName("localhost");
>     db.setDatabaseName("mysql");
>     db.setUserName("root");
>     db.setPassword("123543");
>     if (!db.open())
>         QMessageBox::critical(0,"Database error",db.lastError().text());
>     else
>         QMessageBox::information(0,"connexion à la base","OK");
>    
>     return app.exec();
>   
> }
>
> and I have the following issue:
> -first message: mySQL is displayed: the driver is recognized
> -second message: I have the error:
>
> can't connect to local MySQL server through socket 
> '/opt/local/var/run/mysql5-devel/mysqld.sock' (2)
>
> QMYSQL: unable to connect.
>
> I specify that I have installed (before Qt) mysql5 from the site 
> www.mysql.com. Is there a conflict between the two installation (the 
> second one is an installation via macports of the port "mysql5-devel", 
> followed by the compilation of the mysql plugin, the one which is 
> recognized by the program above)?
>
>
> regards,
>
> lolveley.
>
>
>
>
>
>
>

Message 3 in thread

Hello,
>
> I ran this program:
>
> #include <QtSql>
> #include <QApplication>
> #include <QtGui>
>
>
> int main(int argc,char* argv[]){
>     QApplication app(argc,argv);
>     QSqlDatabase db;
>     QString chaine;
>         for (int i=0;i < db.drivers().count();i++){
>             chaine += db.drivers().value(i);
>             chaine += "\n\r";
>         }       
>     QMessageBox::information(0,"connexion à la base",chaine);
>    
>     db=QSqlDatabase::addDatabase("QMYSQL");
>    
>     db.setHostName("localhost");
>     db.setDatabaseName("mysql");
>     db.setUserName("root");
>     db.setPassword("123543");
>     if (!db.open())
>         QMessageBox::critical(0,"Database error",db.lastError().text());
>     else
>         QMessageBox::information(0,"connexion à la base","OK");
>    
>     return app.exec();
>   
> }
>
> and I have the following issue:
> -first message: mySQL is displayed: the driver is recognized
> -second message: I have the error:
>
> can't connect to local MySQL server through socket 
> '/opt/local/var/run/mysql5-devel/mysqld.sock' (2)
>
> QMYSQL: unable to connect.
>
>
Some more informations:

    * I have installed two versions of mysql: the first one is the
      standard installation from the site mysql.com

          the second one is via macports (specific to macs), the port is 
called "mysql5-devel"

    * the mysql plugin has been installed after the installation of the
      two mysql

    * _mysql said me its socket was "/tmp/mysqld.sock" and I found no
      folder "/opt/local/var/run/mysql5-devel/"_ (this is the heart of
      the problem), so I created this directory and I copied mysqld.sock
      inside it, but the error remains.

    * Last thing, reading the archives of this mailing-list, I saw that
      it was possible - with the purpose of indicate to Qt where
      mysqld.sock is - to modify the file qsql_mysql.cpp and inside it
      to modify the variable unix_socket from NULL to /tmp/mysqld.sock
      (after that, a new compilation of Qt is needed).
      I tried to modify this program, but - is it the change of version
      - I did not found the variable unix_socket (one time but at line
      1000+ and without any NULL around it).

      You know all the story!

      lolveley.


>
>

Message 4 in thread

Hello,
>
> I ran this program:
>
> #include <QtSql>
> #include <QApplication>
> #include <QtGui>
>
>
> int main(int argc,char* argv[]){
>     QApplication app(argc,argv);
>     QSqlDatabase db;
>     QString chaine;
>         for (int i=0;i < db.drivers().count();i++){
>             chaine += db.drivers().value(i);
>             chaine += "\n\r";
>         }       
>     QMessageBox::information(0,"connexion à la base",chaine);
>    
>     db=QSqlDatabase::addDatabase("QMYSQL");
>    
>     db.setHostName("localhost");
>     db.setDatabaseName("mysql");
>     db.setUserName("root");
>     db.setPassword("123543");
>     if (!db.open())
>         QMessageBox::critical(0,"Database error",db.lastError().text());
>     else
>         QMessageBox::information(0,"connexion à la base","OK");
>    
>     return app.exec();
>   
> }
>
> and I have the following issue:
> -first message: mySQL is displayed: the driver is recognized
> -second message: I have the error:
>
> can't connect to local MySQL server through socket 
> '/opt/local/var/run/mysql5-devel/mysqld.sock' (2)
>
> QMYSQL: unable to connect.
>
>
Some more informations:

    * I have installed two versions of mysql: the first one is the
      standard installation from the site mysql.com

          the second one is via macports (specific to macs), the port is 
called "mysql5-devel"

    * the mysql plugin has been installed after the installation of the
      two mysql

    * _mysql said me its socket was "/tmp/mysqld.sock" and I found no
      folder "/opt/local/var/run/mysql5-devel/"_ (this is the heart of
      the problem), so I created this directory and I copied mysqld.sock
      inside it, but the error remains.

    * Last thing, reading the archives of this mailing-list, I saw that
      it was possible - with the purpose of indicate to Qt where
      mysqld.sock is - to modify the file qsql_mysql.cpp and inside it
      to modify the variable unix_socket from NULL to /tmp/mysqld.sock
      (after that, a new compilation of Qt is needed).
      I tried to modify this program, but - is it the change of version
      - I did not found the variable unix_socket (one time but at line
      1000+ and without any NULL around it).

      You know all the story!

      lolveley.


>
>