关于mysql:无法通过MAX_USER_CONNECTIONS在MariaDB中创建用户

Cannot create user in MariaDB with MAX_USER_CONNECTIONS

我正在尝试使用以下语句在MariaDB 10.1中创建用户:

1
 CREATE USER 'exporter' IDENTIFIED BY 'exporter' WITH MAX_USER_CONNECTIONS 3;

但是,此命令失败并显示:

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 'MAX_USER_CONNECTIONS 3' at line 1

省略WITH MAX_USER_CONNECTIONS选项时,它可以工作。


对于<10.2的MariaDB,如果我拆分以下语句,它将起作用:

1
2
CREATE USER 'exporter' IDENTIFIED BY 'exporter';
GRANT [...] WITH MAX_USER_CONNECTIONS 3;

对于较新的版本,请参见此答案。


从MariaDB 10.2.0开始,可以使用提到的语法。

https://mariadb.com/kb/zh/library/create-user/

enter image description here


10.2语法表示密码选项位于资源选项之后。

1
2
3
CREATE USER 'exporter'
    WITH MAX_USER_CONNECTIONS 3
    IDENTIFIED BY 'exporter';