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. Opening Connection Without Password

Opening Connection Without Password

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.0k 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.
  • F Offline
    F Offline
    fft2048
    wrote on last edited by
    #1

    I am trying to open a mySQL connection without a password.
    In my home account, I have a file
    .my.cnf
    In there is the following
    [client]
    password="MyPassword"

    As a result, on the command line, I am able to do the following:
    mysql -u username
    allowing me to login without a password.

    However, I am having trouble doing this via a QT connection.
    I can open the connection as follows:
    db.open("username", "MyPassword")
    However, leaving the password field as "" does not work.
    If I just specify the username, and not password via
    db.setUserName("username")
    then
    db.open();
    It still will not work
    I get the error:
    Access denied for user 'username@localhost' (using password: NO) QMYSQL: Unable to connect
    Is there a connection option that exists allowing me to login with password? This is somewhat critical
    for my application.
    Thanks.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi,

      the trick you use tell the mysql client to use the password stored in .my.cnf.
      The Qt solution could be to read the same file and extract the password; .my.cnf is a INI file so you can use QSettings to read and parse it

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fft2048
        wrote on last edited by
        #3

        mcosta,
        Thanks for the response. At first I thought about parsing the .cnf file myself.
        But the QSettings option worked perfectly!
        Bob

        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