I Want to Undo AN SQL Command on My DB

3 replies
Hey DPs,

I was trying to find a solution to registration new users on my site; and I used an advice from a Wordpress forum to run a particular SQL query. Now when I try to log into my Admin account, the login page just returns to the regular Wordpress login and then refreshes itself.

The initial problem I was trying to solve is that new users that register on my website get an activation e-mail that leads them to a page that asks for "activation key"; and yet nothing in the email sent to them is called an activation key. When they copy and paste the numbers on the URL for account activation, the server replies "invalid activation key"

So, here's what the guy at the Wordpress forum posted awhile back :
Invalid activation key errors can sometimes be fixed by running this query on your DB:

UPDATE wp_users SET user_activation_key = '' WHERE user_activation_key LIKE '%$%'

Be sure to change wp_users to your actual users table if you use a non-default DB prefix.

How does this work? If the user_activation_key field is blank, WP will create a new one that's not invalid.


I copied this and ran it on my DB. Now, I can't even log into my account. That means my users will not also be able to log into their account even though I have used a plugin to disable the need for activation e-mail.

My site is Afrimash | Building the Largest Community of Food Providers for Africa. I need help. I'm not an SQL expert. I was looking for a simple solution.

Your responses will help me. Thanks.
#command #sql #undo
  • Profile picture of the author prima854
    There really isn't any undo query that you can run. There's a rollback command in MS SQL Server (Not sure about MySQL which, with WordPress, is probably what you're using), but it's mostly useless, and you have to not have closed the session since you ran the query. If you still have the session open, try just entering the command "Rollback" (without the quotes) and see what happens.


    There may be a possibility that you can run a query that picks up the activation keys that may be located in another table and drop it in the proper place, but given you're not an SQL expert that probably isn't an option.


    My advice is to restore from backup. You'll have to see if your hosting site is making backups and restore from the most recent backup just before the time you ran that command.


    If there are no backups, you're pretty much out of luck and it will just get complicated no matter what.
    {{ DiscussionBoard.errors[10024056].message }}
  • Profile picture of the author Aravind Murthy
    I don't think that the two issues are connected.

    1. Usually an activation key is required for new users only. So it won't affect your existing users who have already activated and new users will get a new and valid activation key ?

    2. You didn't change passwords. I wouldn't expect you to have trouble to login as admin as a result of that update Statement.

    Wp gurus, Am I missing something here?
    {{ DiscussionBoard.errors[10025334].message }}
  • Profile picture of the author Crystal_Jobs
    @Prima Unfortunately, I think my db backup is not active at the moment. Hostgator has been sending me messages lately that backup failed.

    @Murthy I'm also surprised that I am unable to login after running that query. However, a pop out login box provided by my theme - Kleo is letting me login but Buddypresd login box as well as WordPress login box are not loging in; and no explanation is given.

    A friend has asked me to run another query to fix that. I'm gonna try that now.
    {{ DiscussionBoard.errors[10025513].message }}

Trending Topics