Robert Strauch
Robert Strauch

Reputation: 12896

Cannot create user in MariaDB with MAX_USER_CONNECTIONS

I'm trying to create a user in MariaDB 10.1 with the following statement:

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

However this command fails with:

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

It works when omitting the WITH MAX_USER_CONNECTIONS option.

Upvotes: 3

Views: 1882

Answers (3)

Rick James
Rick James

Reputation: 142258

The 10.2 syntax implies that the password option comes after the resource options.

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

Upvotes: 1

Robert Strauch
Robert Strauch

Reputation: 12896

For MariaDB < 10.2 it works if I split the statements:

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

For newer versions please see this answer.

Upvotes: 4

Daniel W.
Daniel W.

Reputation: 32280

The syntax mentioned is available since MariaDB 10.2.0.

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

enter image description here

Upvotes: 1

Related Questions