Skip to main content
phpMyAdmin Guide
CHAPTER 09 Beginner

How to Manage Users and Privileges in phpMyAdmin

Updated: May 16, 2026
15 min read

# CHAPTER 9

Managing Users and Permissions

1. Introduction

By default, XAMPP uses the root account, which has absolute god-level power over the entire server. If you connect your live WordPress site or Node.js application to the database using the root account, you are committing a catastrophic security sin. If a hacker finds a single vulnerability in your code, they gain the power to drop (delete) every database on your server instantly. In this chapter, we will learn how to use phpMyAdmin's "User accounts" tab to implement the golden rule of cybersecurity: The Principle of Least Privilege.

2. Learning Objectives

By the end of this chapter, you will be able to:
  • Understand the Principle of Least Privilege.
  • Access the User accounts overview.
  • Create a new, dedicated database user.
  • Generate secure passwords.
  • Grant granular, database-specific privileges.
  • Revoke access from old users.

3. The Principle of Least Privilege

The Principle of Least Privilege (PoLP) states that a user or application should only have the exact permissions necessary to perform its job, and absolutely nothing more.
  • Does a web application need the ability to read SELECT data? Yes.
  • Does it need to INSERT and UPDATE data? Yes.
  • Does it ever need the ability to DROP TABLE (delete a table structure)? No.
Therefore, we must create a user account that explicitly blocks DDL (Data Definition Language) commands.

4. Creating a New User Account

Let's create a restricted account just for our company_db.
  1. 1. Go to the main phpMyAdmin homepage (click the logo in the top left).
  1. 2. Click the User accounts tab at the top.
  1. 3. You will see a list of default system users (like root and pma). Leave them alone.
  1. 4. Below the list, click Add user account.
  1. 5. User name: Type webapp_user.
  1. 6. Host name: Select Local (which translates to localhost). This security feature means the user can *only* connect if the application is running on the exact same physical server!
  1. 7. Password: Click the Generate button to create a massive, secure random password (e.g., h7f8d9s8f7d!). Copy this password down; your backend code will need it.

5. Granting Granular Privileges

Now, we must assign permissions to webapp_user.
  1. 1. Scroll down the "Add user account" page to the Global privileges section.
  1. 2. DO NOT CHECK "Check All"! If you do, you just created another root account. Leave every single box unchecked. We don't want them to have global power; we want them to have power over ONE specific database.
  1. 3. Click Go at the very bottom right to create the user.
  1. 4. The screen refreshes. Now, click the Database tab at the top.
  1. 5. Select company_db from the dropdown and click Go.
  1. 6. You are now assigning specific privileges *only* for company_db.
  1. 7. Check: SELECT, INSERT, UPDATE, DELETE.
  1. 8. Leave Unchecked: DROP, ALTER, GRANT.
  1. 9. Click Go.

*Result: You have created a perfectly secure web application user. Even if the app is hacked, the hacker physically cannot delete the tables!*

6. Editing and Revoking Privileges

An employee leaves the company, or you need to downgrade a user's access.
  1. 1. Go back to the User accounts tab.
  1. 2. Find the user in the list.
  1. 3. Click Edit privileges.
  1. 4. You can uncheck boxes to Revoke power, or click the Drop the user button at the very bottom to permanently delete the account.

7. Mini Project: The Analyst Account

Scenario: You hire a Data Analyst. They need to look at the data in company_db to build financial reports, but you don't trust them not to accidentally delete rows.
  1. 1. Create a new user named data_analyst.
  1. 2. Host: % (Any host—meaning they can connect from their laptop at home).
  1. 3. Assign privileges specifically for company_db.
  1. 4. Check ONLY the SELECT box. Leave INSERT, UPDATE, and DELETE completely unchecked.
  1. 5. Click Go.
*(The Analyst has a "Read-Only" account. Their mathematical damage potential is zero).*

8. Common Mistakes

  • Using the % Host Wildcard carelessly: Setting a user's Host to % means they can attempt to log in from anywhere on the global internet. If you are creating a user for a web application that lives on the same server as the database, always set the Host strictly to localhost. This makes it mathematically impossible for external hackers to even attempt a login.

9. Best Practices

  • One User Per Application: If your server hosts 5 different WordPress websites, do NOT use one single user account for all of them. Create wp_user1, wp_user2, etc. If Website A gets hacked, the hacker cannot access Website B's database because the permissions are isolated!

10. Exercises

  1. 1. What cybersecurity principle dictates giving a web application only the exact INSERT/UPDATE permissions it needs, while blocking DROP permissions?
  1. 2. If you want a user to only be able to view data, but never change it, which single privilege checkbox should you select?

11. Database Challenges

You created a user account named api_service. However, when your Node.js application tries to connect to the database, it receives an "Access Denied for user 'api_service'@'192.168.1.50'" error. Explain the architectural networking mistake you made when configuring the "Host name" for this user in phpMyAdmin. *(Answer: You likely set the Host name to strictly localhost, but the Node.js application is running on a different physical server (IP 192.168.1.50). You must edit the user privileges and change the Host name to allow connections from that specific IP address, or use the % wildcard).*

12. MCQ Quiz with Answers

Question 1

When creating a database user account for a standard web application, why is it considered a catastrophic security failure to check the "Check All" box under "Global privileges"?

Question 2

You are configuring an account for a Data Scientist who needs to generate reports from the sales database. To enforce the Principle of Least Privilege, which exact permission(s) should you assign?

13. Interview Questions

  • Q: Define the Principle of Least Privilege. Provide a concrete example of how you would architect user permissions in phpMyAdmin for a multi-tenant server hosting three distinct websites.
  • Q: Explain the security implications of the "Host name" field in phpMyAdmin. Contrast the strict use of localhost versus the % wildcard wildcard.

14. FAQs

Q: I forgot the root password to my XAMPP server. Can I recover it? A: Since XAMPP is a local development environment, it is notoriously hard to recover the root password without diving into configuration files. This is why in production, you never share the root password, and you always create secondary admin accounts as backups!

15. Summary

You are now a gatekeeper. By mastering the User accounts tab, generating secure credentials, and surgically assigning database-specific SELECT/INSERT privileges while strictly blocking destructive DDL commands, you have fortified your database against unauthorized intrusion and catastrophic code bugs.

16. Next Chapter Recommendation

Our data is secure. But right now, our tables are isolated islands. In Chapter 10: Working with Relationships and Foreign Keys, we will learn how to use phpMyAdmin's "Relation view" to visually connect tables together and enforce absolute Referential Integrity.

Finish this Chapter

Save your progress on your learning path and prepare for coding interview challenges.

Discussion

Join the discussion

Log in or create a free account to participate.

Sort: ·