1

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.

4

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' @ '%';
2
  • 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.
    – Philᵀᴹ
    Dec 9 '12 at 1:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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