Skip to content
Menu
DevSecOps Now!!!
  • About
  • Certifications
  • Contact
  • Courses
  • DevSecOps Consulting
  • DevSecOps Tools
  • Training
  • Tutorials
DevSecOps Now!!!

How to Make Yourself an Admin in WordPress (via Database Access)

Posted on October 15, 2025

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Applicable when you have:

  • ๐Ÿ–ฅ๏ธ Server or cPanel access
  • ๐Ÿ—„๏ธ Database access (phpMyAdmin or MySQL CLI)
  • โŒ No access to the WordPress Dashboard

Identify the Database in Use

Before anything, confirm which database your WordPress site is using.

  1. Go to your WordPress installation folder.
  2. Open the file: wp-config.php
  3. Look for these lines: define('DB_NAME', 'your_database_name'); define('DB_USER', 'your_db_user'); define('DB_PASSWORD', 'your_db_password'); define('DB_HOST', 'localhost'); $table_prefix = 'wp_';
  4. Note down the database name and table prefix (e.g., wp_, wz_, etc.).

Open phpMyAdmin

  1. Log into your server control panel (e.g., cPanel, XAMPP, or direct phpMyAdmin).
  2. Select your WordPress database from the left sidebar.
  3. Youโ€™ll see tables like: wp_users wp_usermeta wp_posts ... (Your prefix may differ, e.g., wz_users)

Check Existing Admin Users

You can easily see which users already have admin rights.

Option A: Manual (through phpMyAdmin)

  1. Open the wp_usermeta table.
  2. In the Search tab, find meta_key and enter: %capabilities%
  3. Check rows where meta_value contains: a:1:{s:13:"administrator";b:1;} The corresponding user_id is an admin.
  4. Go back to wp_users โ†’ find the same ID to see which username is the admin.

Option B: Using SQL Query

Run this SQL query directly:

SELECT u.ID, u.user_login, u.user_email, m.meta_value
FROM wp_users u
JOIN wp_usermeta m ON u.ID = m.user_id
WHERE m.meta_key = 'wp_capabilities'
AND m.meta_value LIKE '%administrator%';

This will list all admin accounts instantly.


Make Yourself an Admin (If Youโ€™re Not One Yet)

If you found your user in wp_users but not as an admin, you can assign admin privileges manually.

Step 1: Find your user_id

From wp_users, locate your username โ€” for example:

IDuser_loginuser_email
19rajeshkumarrajesh@devopsschool.com

So here, your user_id = 19.


Step 2: Insert Admin Capabilities

Run these SQL statements (replace wp_ with your actual prefix, and 19 with your user ID):

INSERT INTO wp_usermeta (user_id, meta_key, meta_value)
VALUES (19, 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}');

INSERT INTO wp_usermeta (user_id, meta_key, meta_value)
VALUES (19, 'wp_user_level', '10');

Thatโ€™s it โ€” your account now has full administrator privileges.


Log in to WordPress Dashboard

  1. Go to your site admin page: https://yourdomain.com/wp-admin
  2. Log in with your existing credentials (same username and password from wp_users).
  3. Youโ€™ll now have complete access as an administrator.

Alternative Method (If phpMyAdmin Isnโ€™t Available)

If you have file access but no database access, you can still make yourself admin through your theme.

Steps:

  1. Open your serverโ€™s file manager or FTP.
  2. Go to your active theme directory: /wp-content/themes/your-active-theme/
  3. Edit the file functions.php and add this code at the very end: function make_me_admin(){ $user = 'rajesh'; $pass = 'YourSecurePassword'; $email = 'rajesh@example.com'; if ( !username_exists( $user ) ) { $user_id = wp_create_user( $user, $pass, $email ); $user = new WP_User( $user_id ); $user->set_role( 'administrator' ); } } add_action( 'init', 'make_me_admin' );
  4. Save the file, then reload your site once in the browser.
    • WordPress will auto-create an admin user with those credentials.
  5. After logging in successfully, remove that code from functions.php immediately.

Optional: Reset Your Password via SQL

If you forgot your admin password, you can reset it directly in the database.

Run this command (replace with your username):

UPDATE wp_users SET user_pass = MD5('NewSecurePassword') WHERE user_login = 'rajesh';

Troubleshooting Tips

ProblemLikely CauseFix
You canโ€™t log in even after inserting SQLWrong table prefixDouble-check prefix in wp-config.php
Login shows โ€œIncorrect passwordโ€MD5 missing or wrongEnsure password uses MD5() in SQL
โ€œSorry, you are not allowed to access this page.โ€User not mapped correctlyRe-run both INSERT INTO wp_usermeta statements
You donโ€™t know table namesCheck SHOW TABLES; in SQL or phpMyAdmin sidebar
You get duplicate key errorAlready have wp_capabilities entryUse UPDATE instead of INSERT

Summary

TaskSQL / Step
Find AdminsSELECT ... LIKE '%administrator%'
Make User Admin2x INSERT INTO wp_usermeta
Reset PasswordUPDATE wp_users SET user_pass = MD5('password')
Create Admin via CodeAdd snippet to functions.php

Recommended Best Practices

  • Always backup your database before making edits.
  • Remove any temporary PHP code after it runs.
  • Limit phpMyAdmin access to trusted IPs only.
  • Use strong passwords for all admin accounts.
  • Once restored, review the Users โ†’ All Users page in WordPress and clean up unwanted admin entries.

Post Views: 553
  • WordPress
  • WordPress troubleshooting
Subscribe
Login
Notify of
guest
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
  • Incorrect definition of table mysql.column_stats
  • Mautic and PHP 8.3 Compatibility Guide (2026)
  • Certified AIOps Engineer: The Complete Career Path and Certification Guide
  • How to Rename Apache Virtual Host Files Safely (Step-by-Step Guide for Linux)
  • AIOps Foundation Certification: Everything You Need to Know to Get Certified
  • DevOps to Certified Site Reliability Professional: A Senior Mentorโ€™s Guide
  • Certified Site Reliability Manager Training, Preparation, and Career Mapping
  • Certified Site Reliability Architect: The Complete Career Guide
  • What Is a VPN? A Complete Beginner-to-Advanced Tutorial
  • How to Install, Secure, and Tune MySQL 8.4 on Ubuntu 24.04 for Apache Event MPM and PHP-FPM
  • Complete Guide to Certified Site Reliability Engineer Career
  • Certified DevSecOps Professional Step by Step
  • Certified DevSecOps Manager: Complete Career Guide
  • Certified DevSecOps Engineer: Skills, Career Path and Certification Guide
  • Step-by-Step: Become a Certified DevSecOps Architect
  • Tuning PHP 8.3 for Apache Event MPM and PHP-FPM on Ubuntu: A Complete Step-by-Step Production Guide
  • Complete Step-by-Step Guide to Configure Apache Event MPM, Create index.php, Set Up VirtualHost, and Fix Ubuntu Default Page
  • Convert XAMPP Apache to Event MPM + System PHP-FPM
  • The Gateway to System Observability Engineering (MOE)
  • How to Finetune Apache and Prove It Works: A Real-World Guide to Testing Performance, Concurrency, HTTP/2, Memory, CPU, and Security
  • Building a High-Performance Apache Event MPM + PHP-FPM + MariaDB Stack (Advanced Server Optimization Guide)
  • Master Infrastructure as Code: The Complete Hashicorp Terraform Associate Guide
  • Building a High-Performance Apache Server with Event MPM + PHP-FPM (Step-by-Step Guide)
  • Is XAMPP Safer for Production Than Using Apache and PHP as Root? 2026 Practical Guide
  • Unlock Cloud Security Expertise with Certified Kubernetes Security Specialist (CKS)
  • How to Fix wpDiscuz Not Replacing Default WordPress Comments in Block Themes
  • Complete Guide to Certified Kubernetes Application Developer Certification
  • Overview of Certified Kubernetes Administrator (CKA) Certification
  • How to Install and Configure XAMPP on Ubuntu 24 Server (Latest Version โ€“ 2026 Complete Guide)
  • Mastering the Google Cloud Professional DevOps Engineer

Recent Comments

  1. digital banking on Complete Tutorial: Setting Up Laravel Telescope Correctly (Windows + XAMPP + Custom Domain)
  2. SAHIL DHINGRA on How to Uninstall Xampp from your machine when it is not visible in Control panel programs & Feature ?
  3. Abhishek on MySQL: List of Comprehensive List of approach to secure MySQL servers.
  4. Kristina on Best practices to followed in .httacess to avoid DDOS attack?
  5. Roshan Jha on Git all Commands

Archives

  • April 2026
  • March 2026
  • February 2026
  • January 2026
  • December 2025
  • November 2025
  • October 2025
  • September 2025
  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022

Categories

  • Ai
  • AI Blogging
  • AiOps
  • ajax
  • Android Studio
  • Antimalware
  • Antivirus
  • Apache
  • Api
  • API Security
  • Api Testing
  • APK
  • Aws
  • Bike Rental Services
  • ChatGPT
  • Code Linting
  • Composer
  • cPanel
  • Cyber Threat Intelligence
  • Cybersecurity
  • Data Loss Prevention
  • Database
  • dataops
  • Deception Technology
  • DeepSeek
  • Devops
  • DevSecOps
  • DevTools
  • Digital Asset Management
  • Digital Certificates
  • Docker
  • Drupal
  • emulator
  • Encryption Tools
  • Endpoint Security Tools
  • Error
  • facebook
  • Firewalls
  • Flutter
  • git
  • GITHUB
  • Google Antigravity
  • Google play console
  • Google reCAPTCHA
  • Gradle
  • Guest posting
  • health and fitness
  • IDE
  • Identity and Access Management
  • Incident Response
  • Instagram
  • Intrusion Detection and Prevention Systems
  • jobs
  • Joomla
  • Keycloak
  • Laravel
  • Law News
  • Lawyer Discussion
  • Legal Advice
  • Linkedin
  • Linkedin Api
  • Linux
  • Livewire
  • Mautic
  • Medical Tourism
  • MlOps
  • MobaXterm
  • Mobile Device Management
  • Multi-Factor Authentication
  • MySql
  • Network Traffic Analysis tools
  • Paytm
  • Penetration Testing
  • php
  • PHPMyAdmin
  • Pinterest Api
  • Quora
  • SAST
  • SecOps
  • Secure File Transfer Protocol
  • Security Analytics Tools
  • Security Auditing Tools
  • Security Information and Event Management
  • Seo
  • Server Management Tools
  • Single Sign-On
  • Site Reliability Engineering
  • soft 404
  • software
  • SuiteCRM
  • SysOps
  • Threat Model
  • Twitter
  • Twitter Api
  • ubuntu
  • Uncategorized
  • Virtual Host
  • Virtual Private Networks
  • VPNs
  • Vulnerability Assessment Tools
  • Web Application Firewalls
  • Windows Processor
  • Wordpress
  • WSL (Windows Subsystem for Linux)
  • X.com
  • Xampp
  • Youtube
©2026 DevSecOps Now!!! | WordPress Theme: EcoCoded
wpDiscuz