How to change user password in CockroachDB?
In this tutorial, we are going to figure out a couple of methods to change user password in CockroachDB.
Note that password creation and alteration is supported only in secure clusters for non-root users. The root user must authenticate with a client certificate and key.
1. Using cockroach user command
To change a user password, execute this command:
cockroach user set user_name --certs-dir=certs --password
After executing the command, enter the new password at the command prompt.
2. Using the ALTER USER statement
- Change Password Using a String Literal:
ALTER USER user_name WITH PASSWORD 'strongpassword';
- Change Password Using an Identifier:
ALTER USER user_name WITH PASSWORD strongpassword;
If you want to use the password with mixed uppercase and lowercase characters, use the double quotes:
ALTER USER user_name WITH PASSWORD "StrongPassword";
Need a good GUI tool for CockroachDB on MacOS and Windows? TablePlus is a modern, native tool with an elegant GUI that allows you to simultaneously manage multiple databases such as MySQL, PostgreSQL, SQLite, Microsoft SQL Server, CockroachDB and more.
Download TablePlus for Mac. It’s free anyway!
Not on Mac? Download TablePlus for Windows.