0

I have seen in the answer supplied in the question: How do I open up my MySQL on my Raspberry Pi for Outside / Remote Connections?

And on other sites that the apostrophes ( ' ) in the create user syntax are required.

CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'password';

But i have found that when the apostrophes are omitted around the username and host name it still works.

for example:

CREATE USER jeffrey@localhost IDENTIFIED BY 'password'; 

or even

CREATE USER jeffrey@127.0.0.1 IDENTIFIED BY 'password'; 

will generate a user without problems as far as i can tell.

Image of create user syntax

Image of result of create user syntax

Is this behavior intended or is it bad to do it this way (omitting apostrophes)?

Regards

en_lorithai
  • 1,120
  • 7
  • 13

1 Answers1

1

According to dev.mysql.com/doc/refman/5.7/en/account-names.html:

The user name and host name need not be quoted if they are legal as unquoted identifiers. Quotes are necessary to specify a user_name string containing special characters (such as space or -), or a host_name string containing special characters or wildcard characters (such as . or %); for example, 'test-user'@'%.com'.

So presumably you couldn't use the name table without quoting it:

CREATE USER table@127.0.0.1 ...

But you can use foobar:

CREATE USER foobar@127.0.0.1 ...
Martin
  • 16,093
  • 1
  • 29
  • 48