Mysql 帐户名称中的句点字符

Mysql period character in account names

是否可以在 MySQL 账户名中使用句号?我检查了 documentation 并尝试 google 但没有找到任何令人信服的信息。

可以,但您必须用引号 (") 转义用户名。

例如:

没有引号:

MariaDB [(none)]> create user name.surname;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.surname' at line 1

带引号:

MariaDB [(none)]> create user "name.surname";
Query OK, 0 rows affected (0.00 sec)

是的,仅当您使用引号时,例如

create user "myuser.lastname"