0

I need to check if a databse user exists and if not, create that user.

However, I do not know the statement to check if a user already exits.

How to check if a user already exists in MySQL?

4
Contributors
5
Replies
9
Views
8 Years
Discussion Span
Last Post by Offirmo
Featured Replies
  • [code] select user from mysql.user where user=' '; [/code] you should have access to mysql DB to execute the query Read More

  • 1

    Hi tuse How are you? [QUOTE=tuse;635983]Thanks a lot. Didn't see the 'mysql' database.[/QUOTE] Well, if you had access to grant table mysql.user you would have also been able to SELECT User, Password FROM mysql.user. You got it? Yes, you would be able to hack that mysql database. So it's a … Read More

1
select user from mysql.user where user='  ';

you should have access to mysql DB to execute the query

Votes + Comments
Thanx
1

Hi tuse

How are you?

Thanks a lot.

Didn't see the 'mysql' database.

Well, if you had access to grant table mysql.user you would have also been able to
SELECT User, Password FROM mysql.user. You got it? Yes, you would be able to hack that
mysql database. So it's a good idea that not everybody is allowed to "see" grant table.

Happy hacking !

krs,
tesu

Votes + Comments
oops...i was supposed to give you green rep last time
0

Hi tesu!

I have (somehow) managed to see the mysql database!

0
mysqladmin -u 'user' -p 'password' status

this function returns 0 and a line if the user exists, !0 else.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.