Help › Watch and manage the server

Manage users, roles and privileges

See who may sign in to a database server and what each user and role may do, and create users, set passwords and grant or revoke privileges.

Querlyn 0.1.0 is not released yet. This help describes it ahead of release.

The Users and Roles tab lists the users, roles and groups of a database server, and shows what each may do: its attributes, the roles it belongs to, and its privileges on databases, schemas, tables, views, columns, sequences and routines. You can also see, for one table or other object, who may do what on it.

You change all of this in the same tab. Nothing reaches the server until you apply the changes, and before that you see each change as the SQL Querlyn will run.

SQLite and DuckDB have no users or privileges: their connections have no Users and Roles row, and the commands say so. Neither do CockroachDB, SingleStore, PlanetScale and Azure SQL Database, for reasons of their own that the commands give; see Databases on other engines' protocols.

Open Users and Roles

Select a connection in the sidebar, or be in one of its tabs, and choose Query › Users and Roles, or Users and Roles in the connection's right-click menu. You can also expand a connection in the sidebar and open the Users and Roles row after its databases, or use this link: Query › Users and Roles.

Each connection has one Users and Roles tab. If the connection is not connected, the tab offers Connect.

Read the list

The left side lists the users first, then the roles and groups, by name. The one you are signed in as is marked you, and a superuser is marked superuser.

  • The filter box shows the names that contain what you type. In the list, ⌘ on macOS or Ctrl on Windows and Linux and F goes to it.
  • The server's own users and roles (PostgreSQL's pg_ roles, MySQL's mysql.sys, SQL Server's fixed roles, Oracle's built-in users) are hidden. Built-in (Command Palette › Database: Show Built-in Users and Roles) shows them.
  • Refresh (Command Palette › Database: Refresh Users and Roles) reads everything again.

Select a user or role to see it on the right, in three parts:

PartShows
AttributesWhether it can sign in, superuser and other options, its password's state and expiry, its connection limit, defaults such as its default database, schema or role, how it signs in, and its comment.
MembershipThe roles it belongs to, and for a role, its members. "with admin option" marks a member that may grant the role to others; "default" a role that is on when the user signs in; "after SET ROLE" one that is not (see below).
PrivilegesWhat it was granted, in a grid for each kind of object. On PostgreSQL, also the default privileges that objects created later will get; on Snowflake, the future grants.

A user's grids show what it was granted directly, and also what it has through its roles: the roles it belongs to, their roles in turn, and on PostgreSQL and Amazon Redshift what PUBLIC was granted (see Grant and revoke privileges). A role a user belongs to without inheriting its privileges (PostgreSQL's NOINHERIT) adds nothing. On Snowflake, where only roles hold privileges, a user's grids show those of its roles and cannot be changed there.

On MySQL, MariaDB, Oracle Database and ClickHouse a role a user was granted is on when the user signs in only if it is one of the user's default roles. A role that is not is marked after SET ROLE, in Membership and where a box names the role a privilege comes through: the user has those privileges only once a session turns the role on with SET ROLE. Querlyn reads this from the roles as they are stored; a server set to turn every role on at sign-in (MySQL's activate_all_roles_on_login) does so whatever the mark says.

On PostgreSQL, Amazon Redshift and SQL Server, privileges on objects are read from one database at a time: the one the connection uses. Where the connection's server has more than one, Objects of database chooses another.

See who may do what on an object

Right-click a table, view, routine, schema or database in the sidebar and choose Privileges… (Query › Privileges…). In the table designer, Privileges does the same for the table it designs. The tab then shows one grid: a row for each user or role that holds a privilege on the object, and for a table a second grid for its columns.

Users and Roles (Command Palette › Database: Back to Users and Roles) goes back to the list.

Grant and revoke privileges

In a grid, each box is one privilege on one object. A box shows:

MarkMeans
(empty)Not granted.
✓Granted.
✓+Granted with the grant option: it may grant the privilege to others.
✕Denied (SQL Server): refused even when a role grants it.
○Not granted to it directly, but it has the privilege through a role. Point at the box to see which role, and whether only after SET ROLE.

Click a box to move it to its next state: not granted, granted, with the grant option, denied where the database has it, and back to not granted. A box you changed is outlined until the change is applied or discarded. A click always changes what is granted directly: a privilege a user has through a role stays until it is revoked from the role, or the user leaves the role.

  • To grant something on an object that is not in the grid yet, choose Add Object under the grids and pick it. In an object's grid, Add User or Role adds a row.
  • On MySQL and MariaDB the grant option belongs to an object rather than to one privilege, so it has a column of its own, GRANT OPTION.
  • On ClickHouse, ✕ marks a privilege revoked from a wider grant (granted on the database, revoked on one table). Querlyn shows it but does not change it there.

Change roles and members

In Membership, Add to Role makes the user or role a member of another role, and Add Member adds a member to a role. Remove takes a membership away; Undo keeps it after all.

Change attributes

In Attributes, the switches and fields that the database lets you change can be edited: for example whether a PostgreSQL role can sign in, its options, its connection limit and when its password stops working; a MySQL or Oracle account's lock; a SQL Server login's default database. A changed attribute is marked changed.

Command Palette › Database: Expire Password makes the selected user choose a new password at its next sign-in, on MySQL, MariaDB, Oracle and Snowflake. On PostgreSQL and Amazon Redshift, set Password valid until instead.

Create a user or role

  1. Choose New… (Command Palette › Database: New User or Role…).
  2. Choose what to create, where the database has more than one kind: for example a user or a role; on SQL Server a login, server role, database user or database role; on Amazon Redshift also a group.
  3. Type its name. On MySQL and MariaDB, also the host it may sign in from (% for anywhere).
  4. For a user, type a password, or leave it empty for none. A SQL Server login needs one. For a SQL Server database user, choose the login it belongs to, or none.
  5. Choose Create.

The new user or role is added to the list, marked new, with its CREATE statement in the changes. You can give it privileges and roles before applying.

Set a password

Select the user and choose Set Password… (Command Palette › Database: Set Password…), type the password and choose Set Password in the dialog.

The password field never shows what you type unless you ask it to with the eye button. The password is kept in memory only until the change is applied or discarded. It is never stored, never written to a log or to the query history, and never shown again:

  • In the changes and in the statement console, a placeholder, ••••••••, stands where the password goes.
  • If you open the changes in an editor, the placeholder is in the script too, so the script does not run as it is. Type the password there yourself if you run it by hand.

How the password reaches the server depends on the database:

DatabaseWhat Querlyn sends
PostgreSQLA SCRAM-SHA-256 verifier computed by Querlyn, so the password itself never leaves your computer.
Amazon RedshiftRedshift's MD5 form of the password.
ClickHouseA salted SHA-256 hash of the password.
SQL ServerThe password as a bound parameter, around which the server builds the statement.
Oracle DatabaseThe password as a bind variable, around which a PL/SQL block builds the statement. A password with a double quote cannot be set this way.
MySQL, MariaDBThe password in the statement, which the server keeps out of its logs.
SnowflakeThe password in the statement, over HTTPS; Snowflake hides it in its query history.

If the connection is not encrypted, the dialog says that the password crosses the network as typed.

Drop a user or role

Select it and choose Drop (Command Palette › Database: Drop User or Role). Its row is struck through and its DROP statement is added to the changes; choose Drop again to keep it after all. You cannot drop the user you are signed in as, or the server's built-in users and roles.

The database refuses to drop a user or role that still owns objects or holds privileges (PostgreSQL), or a user that owns objects (Oracle Database). There, a user or role marked to be dropped shows What it owns with a choice:

ChoiceWhat runs before the drop
Keep ThemNothing: the drop fails while it owns something.
Move Them to… (PostgreSQL)REASSIGN OWNED BY … TO …, which makes the role you pick the owner of everything it owns in this database, then DROP OWNED BY …, which revokes what it was granted here.
Drop ThemOn PostgreSQL, DROP OWNED BY …: everything it owns in this database is dropped with its rows, and what it was granted here is revoked. On Oracle Database, the drop becomes DROP USER … CASCADE, which drops every object in its schema.

On PostgreSQL both work on the connection's database only: a role that still owns objects in another database is not dropped, and the error says so. The statements are listed with the other changes, and are asked about like any drop.

Warning: Drop Them removes tables and their rows for good.

Apply the changes

The changes wait at the bottom of the tab, under Changes to apply, each with what it does and the SQL Querlyn will run. A change that takes access away (a revoke, a denial, a removed membership or a drop) is shown in red.

ToChoose
Run themApply Changes (Command Palette › Database: Apply Changes to Users and Privileges)
Forget themDiscard (Command Palette › Database: Discard Changes to Users and Privileges)
Read or run them yourselfOpen in Editor (Command Palette › Database: Open Changes to Users and Privileges in Editor), which opens the script in a new query tab

Before running, Querlyn asks by the connection's environment:

EnvironmentQuerlyn asks before
Local, DevelopmentNothing
Testing, StagingChanges that take access away
ProductionEvery change

The question lists each change it asks about. If you turned on Confirm with Touch ID for the risk level, you answer with your fingerprint; see Confirm with Touch ID. A read-only connection refuses the changes; see Read-only connections.

On PostgreSQL the changes run in one transaction: if one fails, none is applied. On the other databases each statement takes effect as it runs: if one fails, the ones before it stay applied, the changes list marks which ran and where it stopped, and the question says so before you apply. Each statement is listed in the statement console, with passwords replaced by the placeholder.

Warning: Revoking a privilege or dropping a user can stop an application from working at once. Check who depends on it first.

What you are allowed to see

What the tab shows depends on your login. When it cannot read everything, a note says what is missing and which privilege would show it, and the tab shows what it could read.

DatabaseWithout extra rightsTo see everything
PostgreSQLEverything, except which roles have a password.A superuser sees passwords' state too.
MySQL, MariaDBOnly your own account and its privileges.SELECT on the mysql system tables
SQL ServerYour own login and the server roles; part of the database's users.VIEW ANY DEFINITION (logins), VIEW DEFINITION on the database (users)
Oracle DatabaseThe users' names, your own user and roles, and the grants you made or received.SELECT_CATALOG_ROLE or SELECT ANY DICTIONARY
Amazon RedshiftPart of the users, groups and privileges.A superuser, or ACCESS SYSTEM TABLE
SnowflakeThe users your role owns.MANAGE GRANTS, or the USERADMIN role
ClickHouseOnly your user and its roles.SHOW USERS and SHOW ROLES, or access management

On Snowflake, privileges are granted to roles only: a user has the privileges of its roles, so a user has no Privileges grid of its own. Who belongs to which role is read for the first 200 roles.

Databases on other engines' protocols

DatabaseUsers and Roles
YugabyteDB, TimescaleDB, Neon, Supabase, AlloyDB, Aurora PostgreSQLAs on PostgreSQL.
TiDB, Aurora MySQLAs on MySQL 8. TiDB has no connection limit per account.
CockroachDBNot available: CockroachDB keeps privileges outside the PostgreSQL catalog columns Querlyn reads. SHOW ROLES and SHOW GRANTS list them in a query tab.
SingleStoreNot available: SingleStore keeps its users, roles and groups in tables of its own.
PlanetScaleNot available: PlanetScale has no MySQL accounts; passwords and roles are made in its dashboard.
Azure SQL DatabaseNot available: logins are in the master database and most users are contained users with passwords of their own.

See Connect to CockroachDB, TiDB and other compatible databases.

Screen-share mode

While screen-share mode is on, users' names are replaced by placeholders, User 1, User 2 and so on, in the list, the grids, the changes and the questions. Role names stay.

Help for Querlyn 0.1.0. All help topics