In Memgraph, users and their passwords can be created with a simple Cypher query. This level of security is supported within the Community version of Memgraph. For more advanced security features within Memgraph Enterprise, check out role-based access control and auth system integrations.

Creating users

Creating a user can be done by executing the following command:


If the user already exists, you can use IF NOT EXISTS to only create new users.

If the username is an email address, you need to enclose it in backticks (`):


If you want to create a username that includes a space character, you must set the --auth-user-or-role-regex flag to include spaces. For example, --auth-user-or-role-name-regex=[a-zA-Z0-9_.+\-@ ]+.

If the user should authenticate themselves on each session, i.e. provide their password on each session, the part within the brackets is mandatory. Otherwise, the password is set to null, and the user will be allowed to log-in using any password, provided that they use the correct username.

To set or alter a user's password, run the following command:

SET PASSWORD FOR user_name TO 'new_password';

Setting the user's password to null removes the password, allowing the user to log-in using any password:

SET PASSWORD FOR user_name TO null;

To delete a user, run the following command:

DROP USER user_name;

Password encryption algorithm

Memgraph offers multiple password encryption algorithms:

  • BCrypt
  • SHA256
  • SHA256 with multiple iterations (currently set to 1024 iterations)

The above algorithms can be specified at runtime using the flag --password-encryption-algorithm with the appropriate values of bcrypt, sha256 or sha256-multiple.

BCrypt This algorithm is the default algorithm for password encryption. It's the most secure algorithm and has the best protection against brute-force attacks. However, if you're connecting multiple concurrent enterprise users with passwords at the same time, it may not be the best choice for you as you might experience slower performance. The performance is slower only during authentication of the users, and should not degrade once the connection has been established.

SHA256 and SHA256 with multiple iterations SHA256 is an encryption algorithm that's usually not used for password encryption but is fast and secure enough to offer optimal performance when running a lot of concurrent opening connections to Memgraph.


memgraph and memgraph-mage images

If you are using Docker and memgraph or memgraph-mage image enter username and password when connecting manually to Memgraph Lab.

If you are connecting with mgconsole you should add the username and password flags to the docker run command:

docker run -it --entrypoint=mgconsole memgraph/memgraph --host CONTAINER_IP --username=<username> --password=<password>


docker run -it --entrypoint=mgconsole memgraph/memgraph --host --username=vlasta --password=vp


The privileges of the owners of streams and triggers are propagated to the corresponding query executions:

  • in case of streams for the queries returned by the transformations
  • in case of triggers for trigger statements.

This means the execution of the queries will fail if the owner doesn't have the required privileges. There are a few important details:

  • If there are no existing users, no privilege check is performed similarly to regular queries.
  • If a stream or trigger is created without using a logged-in user session, the owner will be Null. From the point when the first user is created such streams and triggers will fail because the lack of owner is treated as a user without any privileges, so no queries are allowed to be executed.
  • Currently, there is no way of changing the owner. The only workaround for this is to delete the stream or trigger and then create it again with another user.

The user who executes the CREATE STREAM query is going to be the owner of the stream. Authentication and authorization are not supported in Memgraph Community, thus the owner will always be Null, and the privileges are not checked in Memgraph Community. In Memgraph Enterprise the privileges of the owner are used when executing the queries returned from a transformation, in other words, the execution of the queries will fail if the owner doesn't have the required privileges.