how about: by asking the DB admin.
what you are asking now is: there is a database on which I have no rights. how do I find a valid username and password for it. looks a lot like trying to 'break' into a secured DB.
actually i am making a application to backup and restore mysql database, for that i have to accept username and password of mysql to execute mysql command.
So, is there any other way to compare user entered username and password with existing mysql username and password.
have you checked the mysql db's configuration itself? here you'll find an example of how to login in mysql through java.
if you actually get logged in, you know you have the right data, if not, try other data.
here is some more information on what you're dealing with. I assume you understand that the creators of MySQL were smart enough not to create a password system that would be hacked with the least bit of effort.