SingleStore User Management
On this page
Configure SingleStore User Accounts
Caution
By default, user accounts are configured independently on each SingleStore aggregator node.root
user is required on leaf nodes.
Also, you can automatically synchronize non-root user accounts across your cluster to avoid manually managing these accounts on each aggregator node.
Secure the Initial SingleStore User Accounts
Configure the root
Password
When SingleStore is installed, the root
user is created on each SingleStore node.root
user.
Once your cluster is deployed, you can also change the password for the root
user with the sdb-admin change-root-password command.root
password for a single SingleStore node.
sdb-admin change-root-password --all --yes --password <secure_password>
Changing the root
password is an online operation for both aggregators and leaves and you do not have to perform any additional operations; however, you must ensure your nodes are running before calling the change-root-password
command.
Warning
Warning
Setting the root
password via a command-line argument is often not secure and SingleStore recommends safer, alternative methods to configure passwords.
While it is convenient to set the root
password using a command-line argument, it is often recommended against this practice for security reasons.root
password supplied as a command-line argument is displayed on-screen and is visible to anyone who is reading the user’s screen.
Some of the more secure, alternative methods to set SingleStore root
password are as follows.
-
Set the
root
password using theMEMSQL_
environment variable.PASSWORD This option is best suited for automated applications. -
As of SingleStore Toolbox 1.
6. 4, Toolbox commands can solicit the root
password interactively from users.The passwords entered in an interactive prompt are not displayed on-screen and are effectively secured from anyone reading the user’s screen. The interactive prompt is invoked if neither the --password
flag nor theMEMSQL_
environment variable has been used to set thePASSWORD root
password.
Deleting Unnecessary Default Users
In MemSQL 6.'root'@'%'
user, which should be configured as described in the previous section.
In MemSQL 5.'root'@'%'
user.
To delete these users, use the DROP USER
command.root
user or another user with sufficient permissions, and run:
DROP USER ''@'localhost';DROP USER ''@'127.0.0.1';DROP USER 'root'@'localhost';DROP USER 'dashboard'@'%';DROP USER 'dashboard'@'localhost';
These additional default users are created in MemSQL installations of 5.
Note that since user accounts are configured independently on each node, whenever you add a new SingleStore node, you should also delete any unnecessary default users on it.
Caution
The users ''@'localhost' and ''@'127.
For example, a login as user ‘alice’ from localhost matches 'alice'@'localhost', ''@'localhost', and 'alice'@'%' in that order of precedence.
For this reason, the 'root'@'localhost'
account is necessary only when the anonymous user accounts for localhost are present.root
user from localhost matches 'root'@'localhost'
, ''@'localhost'
, and 'root'@'%'
in that order of precedence.'root'@'localhost'
account can be removed, leaving only the 'root'@'%'
account.'root'@'localhost'
account in addition to the anonymous user accounts to avoid the possibility of misconfiguring the 'root'@'localhost'
and 'root'@'%'
accounts differently (for example, misconfiguring them with different passwords).
The 'dashboard'@'%'
and 'dashboard'@'localhost'
accounts were used by MemSQL Ops versions prior to 4.
Add a User
To add a user, use the GRANT command.
If you have sync_
enabled on your cluster, log into the master aggregator as the root
user or another user with sufficient permissions, and run:
GRANT <grant_options> TO '<user>'@'<host>' IDENTIFIED BY '<password>'
For example:
GRANT SELECT, INSERT ON db.* TO 'username'@'%' IDENTIFIED BY 'password'
See the GRANT documentation for more details.
Note
If you do not have sync_
enabled, then you must perform the above operations on each aggregator in your cluster.
You can also use Kerberos, SAML, or PAM instead of password-based authentication.
Change a Password for a User
To change a password for a user, you have the following options:
-
Use
GRANT
as shown in the previous section.You must have SUPER
privileges to change another user’s password. -
Use
SET PASSWORD
to create a password hash and assign it to the user.Users can also change their own password with this command. SET PASSWORD FOR 'username'@'host' = PASSWORD('password');
Remove a User
To remove a user, use the DROP USER command.
Similar to other user management operations, if you have sync_
enabled, log into the master aggregator as the root
user or another user with sufficient permissions, and run:
DROP USER '<user>'@'<host>'
If sync_
is not enabled, then you must perform this operation on each aggregator in the cluster.
Inspect Permissions
You can view grants and permissions by querying information_
.
You can also view grants for a user by running SHOW GRANTS:
SHOW GRANTS FOR user@domain;
Set a Failed Login Attempt Lockout Policy
You can specify the number of times a user can enter an incorrect password before they are locked out of the system.
This feature can be enabled per user or per role, in which case every user belonging to that role will be subject to failed login attempt lockout.
Enable the Lockout Policy
To enable the lockout policy:
Set both FAILED_
and PASSWORD_
for the user or role.FAILED_
is the number of failed attempts before the account is locked, for example: 4
.PASSWORD_
is the number of seconds a locked out account must wait before reattempting to log in.
Note
You must set both FAILED_
and PASSWORD_
to enable the feature.
Enable the lockout feature at 4 failed attempts, with a lockout time of 4 hours (14400 seconds) when creating a user:
CREATE USER user1 WITH FAILED_LOGIN_ATTEMPTS = 4 PASSWORD_LOCK_TIME = 14400;
Enabling the feature for a role:
CREATE ROLE general WITH FAILED_LOGIN_ATTEMPTS = 4 PASSWORD_LOCK_TIME = 14400;
If a user is associated with more than one role with different password lock times, the larger PASSWORD_
value is applied.
If a user and a role the user is tied to have conflicting FAILED_
settings, the lower value is applied.
Update Lockout Settings
If the PASSWORD_
value is updated for a role or user, the new setting applies to currently locked accounts.PASSWORD_
is then set to 4 hours, the new limit is enforced and the account will be unlocked 4 hours after it was locked.
If the FAILED_
setting for a locked out user is updated to be higher than the current setting, the user is unlocked.FAILED_
setting.
Unlock a Locked Account
To unlock a locked account:
Use the ALTER USER
command and specify ACCOUNT UNLOCK
.
ALTER USER user ACCOUNT UNLOCK;
If sync permissions is not enabled, ACCOUNT UNLOCK
should be issued on the aggregator where the user is to be unlocked.
If sync_
is enabled, ACCOUNT UNLOCK
should be issued on the Master Aggregator since all user modifications will have to come from the Master.
In this section
Last modified: January 20, 2023