How To check the username of mysql account after installation?

Feb 9th, 2010 | By KC | Category: My SQL Related

I’m you do a name question in JSP n i have to supplement a username of my mysql comment that i forgot. Is there any approach i can know it but re-installing it again?
Thank you

One comment
Leave a comment »

  1. If you don’t know the root user login credentials or some other user account that can GRANT privileges, you’re out of luck and you’ll need to run setup again.

    If you can login as root, then you can query the user table like so:

    USE mysql;
    SELECT user FROM user;

    This should return all user names in the system. However, if you don’t know the password, you’ll need to assign it again as MySQL encrypts the passwords. So lets assume the database name you want your user to have access to is called mydb, then you would assign permissions like so (assumes your username is myUser and you are going to make calls from localhost…if making calls from another computer, replace localhost with that computer’s IP):

    GRANT ALL ON mydb.* TO ‘myUser’@'localhost’ IDENTIFIED BY "yourPasswordHere";

Leave Comment