|
| 1 | +--- |
| 2 | +title: Managing Users of Your Scalingo for MySQL® Addon |
| 3 | +nav: Managing Users |
| 4 | +modified_at: 2025-03-31 12:00:00 |
| 5 | +tags: databases mysql addon |
| 6 | +index: 5 |
| 7 | +--- |
| 8 | + |
| 9 | +Each Scalingo for MySQL® addon comes with a [default database user](#understanding-protected-user). |
| 10 | +You can [create](#creating-a-new-user) as many additional users as needed, |
| 11 | +grant them with the appropriate permissions, and you can [delete](#deleting-a-user) |
| 12 | +them once they are not required anymore. |
| 13 | + |
| 14 | + |
| 15 | +## Listing Existing Users |
| 16 | + |
| 17 | +### Understanding Protected User |
| 18 | + |
| 19 | +When provisioning a new Scalingo for MySQL® addon, the platform creates a |
| 20 | +default user with a random name and password. It also grants this default user |
| 21 | +read and write permissions on the database, using the following queries: |
| 22 | + |
| 23 | +```sql |
| 24 | +GRANT ALL PRIVILEGES ON <database>.* TO '<username>'@'%%' |
| 25 | +``` |
| 26 | + |
| 27 | +{% note %} |
| 28 | +This default user is ***protected*** and thus: |
| 29 | +- can't be renamed, nor removed, |
| 30 | +- its password can't be updated |
| 31 | +{% endnote %} |
| 32 | + |
| 33 | +### Using the Database Dashboard |
| 34 | + |
| 35 | +1. From your web browser, open your [database dashboard]({% post_url databases/mysql/2000-01-01-getting-started %}#accessing-the-mysql-dashboard) |
| 36 | +2. Click the **Settings** tab |
| 37 | +3. In the **Settings** submenu, select **Users** |
| 38 | +4. The list of available users is displayed under the **User Management** |
| 39 | + section |
| 40 | + |
| 41 | +### Using the Command Line |
| 42 | + |
| 43 | +1. Make sure you have correctly [setup the Scalingo command line tool]({% post_url platform/cli/2000-01-01-start %}) |
| 44 | +2. From the command line, run the following command to list the users: |
| 45 | + ```bash |
| 46 | + scalingo --app my-app --addon mysql database-users-list |
| 47 | + ``` |
| 48 | + The output should look like this: |
| 49 | + ```text |
| 50 | + +----------------+-----------+-----------+ |
| 51 | + | USERNAME | READ-ONLY | PROTECTED | |
| 52 | + +----------------+-----------+-----------+ |
| 53 | + | my_app_4553 | false | true | |
| 54 | + | my_app_4553_rw | false | false | |
| 55 | + | my_app_4553_ro | true | false | |
| 56 | + +----------------+-----------+-----------+ |
| 57 | + ``` |
| 58 | + In this example, we can see that the database has 3 users available. One has |
| 59 | + been created along with the addon and is protected, which means it can't be |
| 60 | + removed. Among the two others, one can only read data from the database. |
| 61 | + |
| 62 | + |
| 63 | +## Creating a New User |
| 64 | + |
| 65 | +{% note %} |
| 66 | +The following restrictions apply when creating a new user, regardless of the |
| 67 | +method you use: |
| 68 | + |
| 69 | +- Username **must**: |
| 70 | + - Start with a letter |
| 71 | + - Be between 6 and 16 characters long |
| 72 | + - Contain only alphanumerical characters and underscores (`_`) |
| 73 | +- Password **must**: |
| 74 | + - Be between 24 and 64 characters long. |
| 75 | + - Not contain the character `"` or `'` |
| 76 | +{% endnote %} |
| 77 | + |
| 78 | +### Using the Database Dashboard |
| 79 | + |
| 80 | +1. From your web browser, open your [database dashboard]({% post_url databases/mysql/2000-01-01-getting-started %}#accessing-the-mysql-dashboard) |
| 81 | +2. Click the **Settings** tab |
| 82 | +3. In the **Settings** submenu, select **Users** |
| 83 | +4. Click the **Add a user** button |
| 84 | +5. Fill the **Add a new user** form: |
| 85 | + - Fill a username |
| 86 | + - To grant write abilities to this user, make sure to check the **Write |
| 87 | + (optional)** checkbox |
| 88 | +6. Validate by clicking the **Add this user** button |
| 89 | +7. A secure password is generated automatically and shown in a popup window |
| 90 | + after the user creation. **You will be able to view and copy it only once**. |
| 91 | + |
| 92 | +### Using the Command Line |
| 93 | + |
| 94 | +1. Make sure you have correctly [setup the Scalingo command line tool]({% post_url platform/cli/2000-01-01-start %}) |
| 95 | +2. From the command line, run the following command to create a new user: |
| 96 | + ```bash |
| 97 | + scalingo --app my-app --addon mysql database-users-create <username> |
| 98 | + ``` |
| 99 | + Optionally, if you want to restrict this user to read only abilities, use |
| 100 | + the `--read-only` flag: |
| 101 | + ```bash |
| 102 | + scalingo --app my-app --addon mysql database-users-create --read-only <username> |
| 103 | + ``` |
| 104 | +3. Set the user password: |
| 105 | + - Either chose a password and confirm it |
| 106 | + - Or let the platform generate a password by leaving the field empty |
| 107 | + |
| 108 | + The output should look like this: |
| 109 | + - If you set a password: |
| 110 | + ```text |
| 111 | + User "my_user" created. |
| 112 | + ``` |
| 113 | + - If you let the platform generate a password: |
| 114 | + ```text |
| 115 | + User "my_user" created with password "YANs3y07m5_KJC2MSDGebh8tx1lliFWh2Yb239zVqGQvbElWDjIN7QWspVH92Ul8". |
| 116 | + ``` |
| 117 | + |
| 118 | +## Updating a User Password |
| 119 | + |
| 120 | +{% note %} |
| 121 | +- Setting a user password to a **specific value** can only be done via the |
| 122 | + command line. |
| 123 | +- Please get in touch with our Support Team to update a |
| 124 | + [protected user](#understanding-protected-user) password. |
| 125 | +{% endnote %} |
| 126 | + |
| 127 | +### Using the Database Dashboard |
| 128 | + |
| 129 | +1. From your web browser, [open your database dashboard]({% post_url databases/mysql/2000-01-01-getting-started %}#accessing-the-mysql-dashboard) |
| 130 | +2. Click the **Settings** tab |
| 131 | +3. In the **Settings** submenu, select **Users** |
| 132 | +4. Locate the user you want the password to be updated |
| 133 | +5. Click the **"…"** button next to the user |
| 134 | +6. From the popup menu, select **Reset password** |
| 135 | +7. In the popup window, confirm the reset by typing the name of the user |
| 136 | +8. Validate by clicking the **Confirm** button |
| 137 | +9. A secure password is generated automatically and shown in a popup window |
| 138 | + after the password reset. **You will be able to view and copy it only |
| 139 | + once**. |
| 140 | + |
| 141 | +### Using the Command Line |
| 142 | + |
| 143 | +1. Make sure you have correctly [setup the Scalingo command line tool]({% post_url platform/cli/2000-01-01-start %}) |
| 144 | +2. Update the user password with the following command: |
| 145 | + ```bash |
| 146 | + scalingo --app my-app --addon mysql database-users-update-password <username> |
| 147 | + ``` |
| 148 | +3. An interactive prompt asks you for a password you want to attribute to your user: |
| 149 | + - Either choose a password and confirm it |
| 150 | + - Or let the platform generate a password by leaving the field empty |
| 151 | + The output should look like this: |
| 152 | + - If you set a password: |
| 153 | + ```text |
| 154 | + User "my_user" created. |
| 155 | + ``` |
| 156 | + - If you let the platform generate a password: |
| 157 | + ```text |
| 158 | + User "my_user" created with password "YANs3y07m5_KJC2MSDGebh8tx1lliFWh2Yb239zVqGQvbElWDjIN7QWspVH92Ul8". |
| 159 | + ``` |
| 160 | + |
| 161 | + |
| 162 | +## Deleting a User |
| 163 | + |
| 164 | +### Using the Database Dashboard |
| 165 | + |
| 166 | +1. From your web browser, [open your database dashboard]({% post_url databases/mysql/2000-01-01-getting-started %}#accessing-the-mysql-dashboard) |
| 167 | +2. Click the **Settings** tab |
| 168 | +3. In the **Settings** submenu, select **Users** |
| 169 | +4. Locate the user you want to remove |
| 170 | +5. Click the **"…"** button next to the user |
| 171 | +6. From the popup menu, select **Delete user** |
| 172 | +7. In the popup window, confirm the deletion by typing the name of the user |
| 173 | +8. Validate by clicking the **Confirm** button |
| 174 | + |
| 175 | +### Using the Command Line |
| 176 | + |
| 177 | +1. Make sure you have correctly [setup the Scalingo command line tool]({% post_url platform/cli/2000-01-01-start %}) |
| 178 | +2. Remove the user with the following command: |
| 179 | + ```bash |
| 180 | + scalingo --app my-app --addon mysql database-users-delete <username> |
| 181 | + ``` |
0 commit comments