WordPress does not allow you to change your username by default. It is something you would expect a software like WordPress to have out of the box.
There are many reasons why you would want to change your username. If your username is admin, then you might want to make it less obvious. If your site is open to public registrations, then you might want to change some bad usernames.
Whatever is the reason, there two ways to change a username in WordPress.
Change Your Username Using Code
The first method requires you to play a little with some code. Usernames are stored in your database, so we will run a database query to change your username. You can add the following code to the functions.php file of your theme:
$wpdb->query( "UPDATE wp_users SET user_login = 'NewUsername' WHERE user_login = 'CurrentUsername';" );
You need to replace CurrentUsername and NewUsername in the above code with your current username and new username, respectively. Save the file, and your username will be changed.
Do not forget to remove the code instantly after a refresh as it will run every time your site loads.
Change Your Username Using a Plugin
If you do not want to mess with the code then you can also use Username Changer plugin. After installing this plugin, you can visit your profile in your WordPress Dashboard to change the username.
You can also allow other users to change their username using the plugin settings. And as an admin, you can change anyone’s username.