Site icon Ryadel

WordPress: Recover Access Without Username and Password

10 Must-Have features for a WordPress Website in 2019

Losing access to your WordPress site can be frustrating, especially if you can’t log in to the admin panel or use the password recovery tools. However, if you have access to your site’s files, particularly the wp-config.php file, you can create a new administrator user with a simple code modification.

Steps to Create a New Administrator User

If you have lost your username and password but can modify the wp-config.php file, follow these steps:

  1. Access Your Site’s Files
    • Use an FTP client (e.g., FileZilla) or your hosting provider’s File Manager.
    • Locate the root directory of your WordPress installation.
  2. Modify the wp-config.php File
    • Open wp-config.php with a text editor (e.g., Notepad++, VS Code, or cPanel’s file editor).
    • Scroll to the end of the file and add the following line:
      • Replace newUser with your desired username.
      • Replace newPass with your chosen password.
      • Replace user@email.com with a valid email address.
  3. Save the File and Access Your Site
    • Open your browser and visit your WordPress site.
    • The code will execute upon page load, creating the new user.
  4. Log into Your Dashboard
    • Go to https://yourwebsite.com/wp-login.php.
    • Use the credentials you just set (newUser and newPass).
  5. Assign Administrator Privileges (if necessary)
    • Once logged in, navigate to Users > All Users.
    • Edit the new user and set the role to Administrator.
  6. Remove the Code from wp-config.php
    • After regaining access, remove the line of code you added for security reasons.

Alternative Methods

If the above method doesn’t work, you can try other solutions:

  • Using phpMyAdmin to Modify the Database:
    • Log in to your hosting control panel and access phpMyAdmin.
    • Select your WordPress database and open the wp_users table.
    • Create a new user or reset the password of an existing one.
  • Using WP-CLI (if available):
    • Via SSH terminal, run:

Conclusion

This method provides a quick way to regain access to WordPress without resetting the database or reinstalling the site. However, it is crucial to remove the code after logging in to prevent security risks.
Additionally, consider enabling alternative password recovery options, such as email recovery or password managers, to avoid similar issues in the future.

 

Exit mobile version