Managing Users of Your Scalingo for MySQL® Shared Resources Database
Each Scalingo for MySQL® addon comes with a default database user. You can create as many additional users as needed, grant them with the appropriate permissions, update/reset their password, and delete them once they are not required anymore.
Listing Existing Users
Understanding Protected User
When provisioning a new Scalingo for MySQL® addon, the platform creates a default user with a random name and password. It also grants this default user read and write permissions on the database, using the following queries:
GRANT ALL PRIVILEGES ON <database>.* TO '<username>'@'%'
Using the Database Dashboard
- From your web browser, open your database dashboard
- Click the Settings tab, then select Database users
- The list of available users is displayed under the Manage database users section
Using the Command Line
- Make sure you have correctly set up the Scalingo command line tool
- From the command line, run the following command to list the users:
scalingo --app my-app --addon mysql database-users-listThe output should look like this:
+----------------+-----------+-----------+ | USERNAME | READ-ONLY | PROTECTED | +----------------+-----------+-----------+ | my_app_4553 | false | true | | my_app_4553_rw | false | false | | my_app_4553_ro | true | false | +----------------+-----------+-----------+In this example, we can see that the database has 3 users available. One has been created along with the addon and is protected, which means it can’t be removed. Among the two others, one can only read data from the database.
Creating a New User
The following restrictions apply when creating a new user, regardless of the method you use:
- Username must:
- Start with a letter
- Be between 6 and 16 characters long
- Contain only alphanumerical characters and underscores (
_)
- Password must:
- Be between 24 and 64 characters long.
- Not contain the character
"or'
Using the Database Dashboard
- From your web browser, open your database dashboard
- Click the Settings tab, then select Database users
- Click the Add a database user button
- Fill the Add a new user form:
- Enter a username
- To grant write permissions to this user, check the Write (optional) checkbox. Leave it unchecked to create a read-only user.
- Validate by clicking the Add this user button
- A password is generated automatically and shown in a popup window after the user creation. You will be able to view and copy it only once.
Using the Command Line
- Make sure you have correctly set up the Scalingo command line tool
- From the command line, run the following command to create a new user:
scalingo --app my-app --addon mysql database-users-create <username>Optionally, if you want to restrict this user to read only abilities, use the
--read-onlyflag:scalingo --app my-app --addon mysql database-users-create --read-only <username> - Set the user password:
- Either choose a password and confirm it
- Or let the platform generate a password by leaving the field empty
The output should look like this:
- If you set a password:
User "my_user" created. - If you let the platform generate a password:
User "my_user" created with password "YANs3y07m5_KJC2MSDGebh8tx1lliFWh2Yb239zVqGQvbElWDjIN7QWspVH92Ul8".
Updating or Resetting a User Password
It is possible to reset the password of any non-protected user.
Using the Database Dashboard (Reset Only)
- From your web browser, open your database dashboard
- Click the Settings tab, then select Database users
- Locate the non-protected user for which you want to reset the password
- Open the … menu next to this user, then click Reset password
- In the popup window, confirm the reset by typing the name of the user
- Validate by clicking the Confirm button
- A password is generated automatically and shown in a popup window after the password reset. You will be able to view and copy it only once.
Using the Command Line
- Make sure you have correctly set up the Scalingo command line tool
- Update the user password with the following command:
scalingo --app my-app --addon mysql database-users-update-password <username> - An interactive prompt asks you for a password you want to attribute to your user:
- Either choose a password and confirm it
- Or let the platform generate a password by leaving the field empty The output should look like this:
- If you set a password:
User "my_user" updated. - If you let the platform generate a password:
User "my_user" updated with password "YANs3y07m5_KJC2MSDGebh8tx1lliFWh2Yb239zVqGQvbElWDjIN7QWspVH92Ul8".
Deleting a User
Using the Database Dashboard
- From your web browser, open your database dashboard
- Click the Settings tab, then select Database users
- Locate the non-protected user you want to remove
- Open the … menu next to this user, then click Delete user
- In the popup window, confirm the deletion by typing the name of the user
- Validate by clicking the Confirm button
Using the Command Line
- Make sure you have correctly set up the Scalingo command line tool
- Remove the user with the following command:
scalingo --app my-app --addon mysql database-users-delete <username>