Results 1 to 13 of 13

Thread: QSqlDatabase connection error in QT(Mac) QSqlError-2049, QMYSQL: Unable to connect

  1. #1
    Join Date
    Feb 2015
    Posts
    185
    Thanks
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default QSqlDatabase connection error in QT(Mac) QSqlError-2049, QMYSQL: Unable to connect

    Hi,
    I am getting an error on executing the below line in QT in MAC. Have installed mysql 5.6.23
    The code is as below
    m_drivername = "QMYSQL3";
    ondb = QSqlDatabase::addDatabase(m_drivername);
    When control reaches this line getting the below warning
    QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work.
    QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.


    ondb.setHostName(m_hostName);
    ondb.setDatabaseName(m_databasename);
    ondb.setUserName(m_database_username);
    ondb.setPassword(m_database_password);
    if(!ondb.open())
    {
    qDebug()<<ondb.lastError();
    }

    lastError() prints ==> QSqlError("2049", "QMYSQL: Unable to connect", "Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)")

    Kindly help to resolve this issue in QT in Mac

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSqlDatabase connection error in QT(Mac) QSqlError-2049, QMYSQL: Unable to connec

    Your version of the database engine cannot talk using MySQL 3 protocol. Use QMYSQL driver instead.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2015
    Posts
    185
    Thanks
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: QSqlDatabase connection error in QT(Mac) QSqlError-2049, QMYSQL: Unable to connec

    I tried making use of "MYSQL" still the same.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSqlDatabase connection error in QT(Mac) QSqlError-2049, QMYSQL: Unable to connec

    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Feb 2015
    Posts
    185
    Thanks
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: QSqlDatabase connection error in QT(Mac) QSqlError-2049, QMYSQL: Unable to connec

    I am able to connect into mysql without any issues.
    Below are lines which were got on connecting to mysql
    DTPC-184N:mysql-5.6.23-osx10.8-x86_64 user$ mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 5
    Server version: 5.6.23 MySQL Community Server (GPL)

    Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.

    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  6. #6
    Join Date
    Feb 2015
    Posts
    185
    Thanks
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: QSqlDatabase connection error in QT(Mac) QSqlError-2049, QMYSQL: Unable to connec

    After installing mysql 5.6 in mac 10.9.5

    When I try to run the below lines..
    cd $QTDIR/src/plugins/sqldrivers/mysql
    qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro
    make
    getting error as below
    TPC-184N:mysql user$ qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro
    WARNING: /Applications/QT/5.4/Src/qtbase/src/plugins/sqldrivers/qsqldriverbase.pri:4: Unable to find file for inclusion qt_plugin
    Project MESSAGE: Warning: unknown QT: core-private
    Project MESSAGE: Warning: unknown QT: sql-private
    Project MESSAGE: qtAddLibrary: found framework QtCore in directory /opt/local/Library/Frameworks
    Failure to open file: /Applications/QT/5.4/Src/qtbase/src/plugins/sqldrivers/mysql/Makefile
    Unable to generate makefile for: mysql.pro
    DTPC-184N:mysql user$

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSqlDatabase connection error in QT(Mac) QSqlError-2049, QMYSQL: Unable to connec

    Didn't you already have a mysql plugin? Why are you rebuilding it?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Feb 2015
    Posts
    185
    Thanks
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: QSqlDatabase connection error in QT(Mac) QSqlError-2049, QMYSQL: Unable to connec

    Do I already have. I dont get it.
    How can I check whether its already present.


    Added after 4 minutes:


    ondb = QSqlDatabase::addDatabase(m_drivername);
    ondb.setHostName(m_hostName);
    ondb.setDatabaseName(m_databasename);
    ondb.setUserName(m_database_username);
    ondb.setPassword(m_database_password);
    if(!ondb.open())
    {
    qDebug() << ondb.lastError();
    }
    the below error is thrown, that why I am trying to do that qmake.
    QSqlError("2049", "QMYSQL: Unable to connect", "Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)")
    Last edited by ejoshva; 17th February 2015 at 12:45.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSqlDatabase connection error in QT(Mac) QSqlError-2049, QMYSQL: Unable to connec

    Quote Originally Posted by ejoshva View Post
    Do I already have. I dont get it.
    How can I check whether its already present.
    sqldrivers directory of your Qt installation will contain files with "mysql" in their name (e.g. libqmysql.so or adequate dylib).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Feb 2015
    Posts
    185
    Thanks
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: QSqlDatabase connection error in QT(Mac) QSqlError-2049, QMYSQL: Unable to connec

    Yes I have all the files.
    so you mean to say that plugin is already created.

    but still I am not able to connect to db through code.

    getting the error on checking ondb.lastError()
    QSqlError("2049", "QMYSQL: Unable to connect", "Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)")
    I am able to connect to the db through mysql workbench

    please guide me to get rid of this issue.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSqlDatabase connection error in QT(Mac) QSqlError-2049, QMYSQL: Unable to connec

    Quote Originally Posted by ejoshva View Post
    Yes I have all the files.
    so you mean to say that plugin is already created.

    but still I am not able to connect to db through code.

    getting the error on checking ondb.lastError()
    QSqlError("2049", "QMYSQL: Unable to connect", "Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)")
    I am able to connect to the db through mysql workbench

    please guide me to get rid of this issue.
    I already gave you a link to the site describing the problem. Your problem is not in Qt but in a connection between your client library and server. Make sure your client (your app) uses a client library (libmysqlclient) which is compatible with your server and that they talk using a proper protocol.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #12
    Join Date
    Feb 2015
    Posts
    185
    Thanks
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: QSqlDatabase connection error in QT(Mac) QSqlError-2049, QMYSQL: Unable to connec

    I did follow all the steps provided in that link. But still no success.

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSqlDatabase connection error in QT(Mac) QSqlError-2049, QMYSQL: Unable to connec

    Quote Originally Posted by ejoshva View Post
    I did follow all the steps provided in that link. But still no success.
    Then try googling for other info. Without sitting in front of your computer we wouldn't be able to help anyway. Make sure your application is using the client library you think it is using.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 5
    Last Post: 27th January 2014, 23:22
  2. Replies: 1
    Last Post: 3rd August 2012, 12:32
  3. "QMYSQL: unable to connect"
    By anteevy in forum Newbie
    Replies: 7
    Last Post: 16th October 2010, 14:05
  4. Mysql unknown database, QMYSQL unable to connect
    By lixo1 in forum Qt Programming
    Replies: 3
    Last Post: 14th July 2010, 22:39
  5. Replies: 3
    Last Post: 22nd June 2006, 17:27

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.