Adding a user to a database and assigning appropriate privileges is crucial for managing database access securely.
Follow these steps to associate a user with a database and control their permissions in cPanel:
Step 1: Log in to cPanel
- Open your web browser and navigate to your cPanel login page (e.g.,
https://yourdomain.com:2083
). - Enter your username and password, then click Log in.
Step 2: Access the MySQL Databases Tool
- Scroll down to the Databases section in the cPanel dashboard.
- Click on MySQL Databases.
Step 3: Add a User to a Database
- Scroll to the Add User to Database section.
- Select the database user from the User dropdown menu.
- Select the database you want to associate with the user from the Database dropdown menu.
- Click Add to link the user to the database.
Step 4: Assign Privileges to the User
- After adding the user to the database, you’ll be redirected to the Manage User Privileges page.
- Select the privileges you want to grant to the user:
- All Privileges: Grants full control of the database, including creating, modifying, and deleting tables and data. Recommended for applications requiring full access.
- Specific Privileges: Choose only the permissions required for the user’s role (e.g.):
- SELECT: Allows the user to read data.
- INSERT: Allows the user to add new data.
- UPDATE: Allows the user to modify existing data.
- DELETE: Allows the user to remove data.
- Once you’ve selected the privileges, click Make Changes to save.
Step 5: Verify the User and Privileges
- Return to the MySQL Databases page.
- Scroll down to the Current Databases section.
- Verify that the user is listed alongside the database with the correct privileges.
Tips for Managing Database Users and Privileges
- Grant Only Necessary Permissions: For security, assign the minimum privileges needed for the user’s tasks.
- Use Descriptive Usernames: Create usernames that clearly indicate their purpose to keep things organized.
- Backup Credentials: Securely store the database name, username, and password for future use.
By adding a user to a database and assigning privileges in cPanel, you ensure controlled and secure access for applications or team members interacting with the database.