Database

Managing Database Users

Database user accounts can be used to control individuals’ or applications’ access to the databases in a Database instance. You might do this to limit access to information, or to limit damage if someone makes a mistake or some application code goes haywire.

In this section, we are going to learn how to add, modify and remove the users for a Database instance and manage their access.

Create a new Database User

  1. Navigate to the Project / Database / Instances page. Database instance list page
  2. Click your tutorial instance name and select the Users tab. Database users page
  3. Click the Create User button. button
  4. In the Create User dialog, enter johnny in the Name field and a strong password in the Password field. Enter tutorial in the Initial Database field, or the name of the database you created earlier. Create user dialog
  5. Click the Create User button.
  6. You should see the johnny user listed. User tab list page

Note
The tutorial user we just created has credentials that permit login from any IP address (assuming that this is permitted by the Database instance). If you provide a value in the Host field, you can restrict the user so that they can only login from a specific machine.

Editting Database User

In this exercise, we are going to rename the user to tutorial_renamed and change their password.

  1. Navigate to the Project / Database / Instances page.
  2. Click on the tutorial instance name and select the Users tab.
  3. Click the Edit User from the actions list of one of the users. Edit  user dialog
  4. In the Edit User dialog, enter the new preferred name in the New Name field and a new strong password in the New Password field. Edit  user dialog
  5. Click Apply Changes button. The password has been updated and you will see that the username has been changed to what you entered.

You can also modify the Host field this way.

Adding and Removing Database access

A Database User is initially allowed to access databases in the Initial Database list. Access to databases can be added and removed via the Manage Access action.

In this exercise, we are going to remove the tutorial user’s access to the tutorial database.

  1. Navigate to the Project / Database / Instances page.
  2. Click on the tutorial instance name and select the Users tab.
  3. Click the Manage Access from the actions list of user tutorial.
  4. In the Database Access page, look for the row for the tutorial database. It should currently have Yes in the Accessible column.
  5. Click the Revoke Access button, and the row should shortly update to say No in the Accessible column.
  6. To restore access, you could then click the Grant Access button.
  7. You can use your browser’s back button to return to the Database Instance page.

Note
The access control functionality provided by the Dashboard is a subset of that which is (typically) available using the database’s command line tool. For with the mysql command allows you control a user’s privileges down to the level of a single database table. Please refer to the relevant database user documentation for more details.

Removing a Database User

The procedure for removing a user from a Database instance is straightforward.

  1. Navigate to the Project / Database / Instances page.
  2. Click on the tutorial instance name and select the Users tab.
  3. Select the Delete User action for the tutorial user.
  4. In the Confirm Delete User dialog, click Delete User.

Caution
Deleting a user or removing a users access to a database may have the effect of stopping an application from working if it uses the user to login.