WordPress: Change Author ID / Attribution On All Posts In a Single Pass

I can access my MySQL database using the command line option provided by vps provider. How do I change author ID or attribution on all wordpress blog posts in a single pass?

First, backup your wordpress database, enter:

mysqldump -u user -p blog-db-name-here > /path/to/backup/dir/blog.db.sql
WARNING! These examples may crash your blog or database if not executed with care. Make a backup – it cannot be stressed enough how important it is to make a backup of your files and mysql database before you do this.

Type the following shell command to connect to your blog database:

mysql -u user -p blog-db-name-here


mysql -u user -h server.ip.here -p blog-db-name-here

Sample outputs:

Enter password: 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15275063
Server version: 5.1.61-log Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Type the following command to list all authors IDs at mysql> prompt:

mysql> SELECT ID, display_name FROM wp_users;

Sample outputs:

| ID | display_name |
|  1 | Vivek Gite   |
|  2 | nixcraft     |
2 rows in set (0.04 sec)

In this output, I’ve two ID of the user. I’d like to change ID #2 (nixcraft) to ID #1 (Vivek Gite). In other words set post author to ID#1 for all posts where post author ID already set to ID#2. Type the following MySQL command:

mysql> UPDATE wp_posts SET post_author='1' WHERE post_author='2';

Sample outputs:

Query OK, 110 rows affected (0.13 sec)
Rows matched: 110  Changed: 110  Warnings: 0

Quit the mysql, enter:

mysql> quit

You need to flush cached post by visiting your wp-content/cache/ directory and delete all the files. If you are using memcached type the following command to flush memcahed cache:

echo "flush_all" | nc 11211

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 2 comments so far... add one

CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
2 comments… add one
  • krishna May 7, 2012 @ 9:04

    Nice web and nice posts, keep doing the good work, thank you.

  • Pranav Aug 12, 2012 @ 17:54

    Thank you Vivek! I had the exact need and this post saved my time like anything. Some how the bulk edit within WordPress was rendering the site unavailable for few mins even with small number of posts.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @ webmaster@cyberciti.biz