Check if user exists iin mysql?

Posted on 2007-10-12
Last Modified: 2013-11-26

is there away to check if the user and password works when making a connection to a database without connection and then catch the exception

MySQL, 5 VB.Net, VS 2005
Question by:AWestEng
    LVL 17

    Accepted Solution

    If you can access the DB with a different user/pass then you can test any other user/pass with:
      IF(COUNT(*) > 0, 'OK', 'Failed') as Status
      user = 'test_username' AND
      password = password('test_password');

    You might have to use `old_password('test_password')` function if you are running an older version of MySQL.

    Or you meant something else?
    LVL 1

    Author Comment

    great man.. thx

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now