Change WordPress posts author en masse without a plugin

If after a blog transfer or import etc you need to change the author of several posts, give them some author, if the author field is now blank, or attribute them to a different author, you can do it easily without a plugin (which may not even exist), just by using PhpMyAdmin. Enter PhpMyAdmin and create a full backup of your database, then click on the SQL option to perform a query. If you know the IDs of the authors you need to change you may skip this step, otherwise let the database display them:

SELECT ID, display_name FROM wp_users;

To attribute all posts to a user with ID, let’s say, 2, just perform this operation:

UPDATE wp_posts SET post_author=2;

If you don’t want everything to go to a single author, but only posts by Jim to become now posts by Mary, use this code (assuming that Jim’s ID is 1 and Mary’s ID is 2):

UPDATE wp_posts SET post_author=1 post_author=2;