943,682 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Marked Solved
  • Views: 21752
  • MySQL RSS
Jun 27th, 2008
0

Check if user exists

Expand Post »
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?
Similar Threads
Reputation Points: 32
Solved Threads: 14
Junior Poster
tuse is offline Offline
173 posts
since Jul 2007
Jun 27th, 2008
1

Re: Check if user exists

MySQL Syntax (Toggle Plain Text)
  1. SELECT user FROM mysql.user WHERE user=' ';

you should have access to mysql DB to execute the query
Reputation Points: 22
Solved Threads: 9
Junior Poster in Training
varmadba is offline Offline
83 posts
since Jun 2008
Jun 27th, 2008
0

Re: Check if user exists

Thanks a lot.

Didn't see the 'mysql' database.
Reputation Points: 32
Solved Threads: 14
Junior Poster
tuse is offline Offline
173 posts
since Jul 2007
Jun 27th, 2008
1

Re: Check if user exists

Hi tuse

How are you?

Click to Expand / Collapse  Quote originally posted by tuse ...
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
Last edited by tesuji; Jun 27th, 2008 at 7:08 pm.
Reputation Points: 158
Solved Threads: 98
Master Poster
tesuji is offline Offline
720 posts
since Apr 2008
Jun 28th, 2008
0

Re: Check if user exists

Hi tesu!

I have (somehow) managed to see the mysql database!
Reputation Points: 32
Solved Threads: 14
Junior Poster
tuse is offline Offline
173 posts
since Jul 2007
Dec 6th, 2011
0

better way

MySQL Syntax (Toggle Plain Text)
  1. mysqladmin -u 'user' -p 'password' status

this function returns 0 and a line if the user exists, !0 else.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Offirmo is offline Offline
1 posts
since Dec 2011

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: Crystal reports for SQL Database
Next Thread in MySQL Forum Timeline: Add Image to mySQL from vb.net





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC