Changing the admin username in WordPress requires direct interaction with the database. Here's how to do it:
1. Backup Your Database
Before making any changes, it's crucial to create a backup of your WordPress database. This ensures you can restore your website to its previous state if something goes wrong.
2. Access Your Database
You can access your database through your hosting control panel or using a database management tool like phpMyAdmin.
3. Locate the wp_users
Table
Once you're in your database, locate the wp_users
table. This table stores all user information, including usernames and passwords.
4. Update the Username
Find the row corresponding to your admin user. You can identify it by the user ID (usually 1 for the admin user). Open the row and locate the user_login
column. Change the username in this column to your desired new username.
5. Save Changes
After updating the username, save the changes to the wp_users
table.
6. Update User Login in wp-config.php
Open the wp-config.php
file in your WordPress root directory. Locate the following line:
define( 'AUTH_KEY', 'your_unique_key' );
Change the value of AUTH_KEY
to a new unique string. This ensures that the old admin username cannot be used to access your website.
7. Update User Login in wp-login.php
Open the wp-login.php
file in your WordPress root directory. Locate the following line:
$user_login = $_POST['log'];
Change $user_login
to your new admin username.
8. Test Login
After making these changes, try logging into your WordPress dashboard with your new username and password.
Important Note: Remember to update any references to your old admin username in your website's code, plugins, or themes.