Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Other than the obvious, what is the difference between:

drop user user_01@host01;

and

drop user 'user_01'@'host01';

In a sample test, they both achieved the same result. From Account Names docs (5th bullet point), looks like they are not the same ... yet they appear to do the same thing ... ?

MySQL 5.5 on Centos 6.x.

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

They are identical.

The bullet point you mention states:

The user name and host name parts, if quoted, must be quoted separately. That is, write 'me'@'localhost', not 'me@localhost'; the latter is interpreted as 'me@localhost'@'%'.

And that is what you did, you quoted them separately. In other words, all these are equivalent:

drop user    user_01@host01;

drop user   user_01 @ host01 ;

drop user  'user_01'@'host01';

drop user 'user_01' @ 'host01' ;

And if you wrote:

drop user 'user_01@host01';

... it would be interpreted as:

drop user 'user_01@host01' @ '%';
share|improve this answer
    
Thanks @Phil. So I'm reading (perhaps incorrectly) the second one as drop the user "user_01@host" logging into the db from host "%" ... which is different from "user_01" logging in from "host01" ... which would be two different commands. Sorry, I am still lost as to how they are identicial ... )-: –  KM. Dec 8 '12 at 14:04
    
They are identical because the parts either side of the @ sign are quoted individually. drop user 'user_01@host01'; has both parts either side of the @ sign between the same quotation marks. Maybe English isn't your native language - the documentation is very clear in this regard. –  FreshPhilOfSO Dec 9 '12 at 1:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.