Title: Change author via SQL query
Last modified: August 30, 2016

---

# Change author via SQL query

 *  [Klaymen](https://wordpress.org/support/users/klaymen/)
 * (@klaymen)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/change-author-via-sql-query/)
 * I have a lot of articles assigned to Author 1 and I need them to be assigned 
   to Author 2. How could I do this? I can’t waste my time in the admin panel changing
   them one by one, even with the quick edit function, so maybe a simple SQL query
   I can run? Some help?

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [brandonzundel](https://wordpress.org/support/users/brandonzundel/)
 * (@brandonzundel)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/change-author-via-sql-query/#post-6791253)
 * If it’s all of their articles, you could remove author 1, and attribute all their
   content to author 2. That’d be the quickest way without messing with the database
   directly.
 *  Thread Starter [Klaymen](https://wordpress.org/support/users/klaymen/)
 * (@klaymen)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/change-author-via-sql-query/#post-6791279)
 * Thank you for your reply, but I don’t want to delete that user… as it is the 
   used I log in with. It’s the admin user. I have “Mysite User” and “Mysite”.. 
   and I need all the articles to be posted under “Mysite”, if possible.
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/change-author-via-sql-query/#post-6791284)
 * You’d need to do it with an SQL query.
 * As a (very rough and not at all tested) example…
 *     ```
       UPDATE wp_posts -- Make sure to set your own table prefix here
       SET post_author = 2  -- The new author ID
       WHERE post_author = 4;  -- The old author ID
       ```
   
 * That will transfer every post created by the user ID 4 to the user ID 2.
 * Just remember that you should always take a backup of your database before doing
   any manual changes like this, just in case something bad does happen.
 *  Thread Starter [Klaymen](https://wordpress.org/support/users/klaymen/)
 * (@klaymen)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/change-author-via-sql-query/#post-6791286)
 * Thank you so much!
    Then in the SQL query field in cPanel I would need to use
   this:
 * `UPDATE wp_posts SET post_author = 2 WHERE post_author = 4;`
 * right? Correct me if I’m wrong. Obviously changing the fields as you said (and
   making a db backup before).
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/change-author-via-sql-query/#post-6791288)
 * Yes, that’s correct.
 *  Thread Starter [Klaymen](https://wordpress.org/support/users/klaymen/)
 * (@klaymen)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/change-author-via-sql-query/#post-6791318)
 * That worked, thank you!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Change author via SQL query’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 3 participants
 * Last reply from: [Klaymen](https://wordpress.org/support/users/klaymen/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/change-author-via-sql-query/#post-6791318)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
