Changing User Passwords in the Database
If an admin user forgets his/her password, he/she cannot retrieve it using the Management Console. In such a scenario, he/she has to change the password by running the chpasswd.sh
script located in the <PRIVATE_PAAS_HOME>/bin/
directory on the machine that hosts the Carbon server.
Before executing this script, the Carbon instance should be shut down.
Prerequisites
Install Apache Ant on your machine.
If you are using MySQL, copy the MySQL JAR to the
<PRIVATE_PAAS_HOME>/repository/lib/
directory. The latter is required because the script does not communicate with the libraries in the<PRIVATE_PAAS_HOME>/repository/components/lib/
directory.
Required information
To change a user's password, you need to provide the following information:
- Carbon database URL: By default, WSO2 Private PaaS is shipped with H2 database so the default URL is
jdbc:h2:repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE
. This URL may change if a different database was specified during the installation. Then the URL will be in the form ofjdbc:h2:<PRIVATE_PAAS_HOME>/repository/database/WSO2CARBON_DB
. - Database driver class: For the default H2 database, the driver will be automatically picked up by the system. If a different database is used, the driver class needs to be specified.
- Database's username and password: For the default H2 database, the default username and password will be used by the system. However, if a different username/password is used, you are required to reset the admin password.
- Username and new password of the user whose password is to be changed: If you do not provide these as command line arguments, you will be prompted for it during execution.
The command line options available for chpasswd
is as follows:
Command Line Option | Description | Mandatory? |
---|---|---|
| The database URL | Yes |
| The database driver class | No |
| The username for the database | No |
| The password for the database | No |
| The username of the user whose password needs to be changed. | No |
| The new password of the user whose password needs to be changed. | No |
If the database path includes directory names with spaces, the whole URL needs to be included within quotations.
Changing the password on H2 DB
If you are using the H2 database the Linux command to change the password will be as follows:
chpasswd --db-url "<H2-DATABASE-URL>"
For example:
chpasswd --db-url "jdbc:h2:$CARBON_HOME/repository/database/WSO2CARBON_DB"
The following message is displayed if the password is updated successfully:
Password of user [username] updated successfully.
Changing the password on MySQL DB
If you are using a MySQL database the Linux command to change the password will be as follows:
./chpasswd.sh --db-driver com.mysql.jdbc.Driver --db-username <USERNAME> --db-password <PASSWORD> --username <ADMIN-USERNAME> --new-password <ADMIN-NEW-PASSWORD> --db-url <MYSQL-DB-URL>
For Example:
./chpasswd.sh --db-driver com.mysql.jdbc.Driver --db-username root --db-password mysql --username admin --new-password abc123 --db-url jdbc:mysql://10.134.130.126:3306/userstore