SQL Query to Update Admin Email

After pushing a staging site to production I have [email protected] set as the admin email which I need to change. Obviously I can't access that email to verify the change because it doesn't exist so I wrote this query:

UPDATE wp_options SET option_value = '[email protected]' WHERE option_name = 'admin_email'

I found this related answer but I do not use phpMyAdmin.

Is this an OK method to override this? Or is there a more proper method?

Topic email-verification admin database Wordpress

Category Web


While your SQL query will probably do the trick, you don't need to interface directly with the database to accomplish this.

The preferred methods would by using Wordpress' update_option() function or by running the WP-CLI command:wp option update.

Via update_option()

To override the admin email change confirmation process, add the following to your functions.php file and hit "save changes".

update_option( 'admin_email', '[email protected]' );

Then once you've verified that the change worked, you can go back to your functions.php and remove the snippet.


Via WP-CLI

If you have WP-CLI installed, you can run the following command from your shell/terminal (much faster):

wp option update admin_email [email protected]

If WP-CLI is owned by root, you'll obviously need to run it with sudo. Success will give you the following output:

Success: Updated 'admin_email' option.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.