Results 1 to 13 of 13

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  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.


Similar Threads

  1. Replies: 5
    Last Post: 27th January 2014, 22:22
  2. Replies: 1
    Last Post: 3rd August 2012, 11:32
  3. "QMYSQL: unable to connect"
    By anteevy in forum Newbie
    Replies: 7
    Last Post: 16th October 2010, 13:05
  4. Mysql unknown database, QMYSQL unable to connect
    By lixo1 in forum Qt Programming
    Replies: 3
    Last Post: 14th July 2010, 21:39
  5. Replies: 3
    Last Post: 22nd June 2006, 16: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.