Changing Your WordPress Username Using SSH

MySQL command line goodies, right from the comfort of your chair.


Since WordPress doesn’t allow you to change your username without digging into your website’s MySQL database, I’ll walk you through a short and painless process of changing it using SSH (secure shell) on an Ubuntu server.

Note: A much easier alternative is to simply make a new user with administrative privileges and delete your old account afterward. Those with cPanel hosting may also have a slightly easier time if you’re unfamiliar with the command line, but that’s beyond the scope of this quick how-to.

Feel free to ask about the cPanel alternative in the comments, however! Also, as with changing anything on your server or installation, always make backups before doing anything.

All right, so I’ll assume you know how to log into your server using SSH, so we’ll start with logging into the MySQL database. Go ahead and type the below command into your console.

mysql -u root -p

The password prompt should come up, so enter your MySQL password. Now let’s go ahead and see your databases. Note that MySQL needs a semicolon at the end of commands before it’ll do anything.

SHOW DATABASES;

A list of your databases should show up, from here recall which one you’re using for your WordPress installation. For our purposes, I’ll just call the database pressword. Go ahead and use the database. The table within the database will be wp_users (the wp_ prefix may differ on your installation).

USE pressword;
SHOW TABLES;
SELECT * FROM wp_users;

The last command will show you the wp_users table, which is where we’ll need to be. Lastly, we’ll need to use the following command to change our username.

UPDATE wp_users SET user_login='NewGuy' WHERE user_login='OldGuy';

Which would change our username from OldGuy to NewGuy.

Also, if you want to get your author URL changed to reflect your username, you can also edit your nicename while you’re at it.

UPDATE wp_users SET user_nicename='newguy' WHERE user_nicename='oldguy';

All done! Go ahead and

exit

and check out your WordPress site.

You’ll need to log in again, but everything should be good to go from here.