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
- Navigate to the
Project
/Database
/Instances
page. - Click your
tutorial
instance name and select theUsers
tab. - Click the
Create User
button. - In the
Create User
dialog, enterjohnny
in theName
field and a strong password in thePassword
field. Entertutorial
in theInitial Database
field, or the name of the database you created earlier. - Click the
Create User
button. - You should see the
johnny
user listed.
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.
- Navigate to the
Project
/Database
/Instances
page. - Click on the
tutorial
instance name and select theUsers
tab. - Click the
Edit User
from the actions list of one of the users. - In the
Edit User
dialog, enter the new preferred name in theNew Name
field and a new strong password in theNew Password
field. - 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.
- Navigate to the
Project
/Database
/Instances
page. - Click on the
tutorial
instance name and select theUsers
tab. - Click the
Manage Access
from the actions list of usertutorial
. - In the
Database Access
page, look for the row for thetutorial
database. It should currently haveYes
in theAccessible
column. - Click the
Revoke Access
button, and the row should shortly update to sayNo
in theAccessible
column. - To restore access, you could then click the
Grant Access
button. - 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.
- Navigate to the
Project
/Database
/Instances
page. - Click on the
tutorial
instance name and select theUsers
tab. - Select the
Delete User
action for thetutorial
user. - In the
Confirm Delete User
dialog, clickDelete 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.