SQL to Change User Email in WordPress

Published: 3 Mar 2023

This page explains how to change user email address in the WordPress database directly with a SQL query.

General user email change SQL query

The email address for each user is stored in the wp_users table in the column named user_email.

You need to update the value in this column, in the row which belongs to the particular user.

This is general structure of the SQL query:

UPDATE `wp_users` 
SET `user_email` = '...'  -- new email address
WHERE ...  -- something to identify the user
;

It is important to include the WHERE clause in your SQL query, otherwise you assign the new email address to all your WordPress users!

The WHERE clause has several variants, depending on how you want to identify the user – by ID number, username, or old email.

Changing email for user identified by user ID number

If you know the user ID, put it in the SQL WHERE clause (the column name is ID).

In the example below, we will change the email to "new@wpdir.com" for the person with WordPress user ID = 123.

UPDATE `wp_users` 
SET `user_email` = 'new@wpdir.com' 
WHERE `ID` = 123;

Notice the quotes around the email address are standard single quotes (which means it is a string), unlike the quotes around SQL table and column names, and unlike the user ID value 123 (which has no quotes because it is an integer).

Changing email for user with given username (login)

If you don't know the WordPress user ID number, but do know the username, you can make the WHERE clause use the user_login column.

The example below changes email address for the user with WordPress username "wpdir".

UPDATE `wp_users` 
SET `user_email` = 'new@wpdir.com' 
WHERE `user_login` = 'wpdir';

Now there are single quotes around both the new email address and the username, as both are strings.

Changing email if you know the old email

Similarly to username, we can identify the user by their old email address. The column name is user_email. It is a string, so don't forget single quotes.

UPDATE `wp_users` 
SET `user_email` = 'new@wpdir.com' 
WHERE `user_email` = 'old@wpdir.com'.

By remaining on this website or using its content, you confirm that you have read and agree with the Terms of Use Agreement.

We are not liable for any damages resulting from using this website. Any information may be inaccurate or incomplete. See full Limitation of Liability.

Content may include affiliate links, which means we may earn commission if you buy on the linked website. See full Affiliate and Referral Disclosure.

We use cookies and similar technology to improve user experience and analyze traffic. See full Cookie Policy.

See also Privacy Policy on how we collect and handle user data.

© 2024 WPDir