Managing your wordpress sites in command-line with wp-cli

Earlier today I was trying to reset my wordpress admin password using the method mentioned here, but got no luck. So, I's looking around the Internet and found this super great tool names wp-cli:

http://wp-cli.org/

It is a set of command-line tools for helping you to manage your wordpress installations. You can do a lot of things using wp-cli, such as:

* Reset users password.
* Install plugin
* Or even create or delete blog posts.

To install wp-cli:

1. Login to your server using a sudo user (not root)

2. Download wp-cli.phar:

$ curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

3. Check if it works:

$ php wp-cli.phar --info

4. To be able to type just wp, instead of php wp-cli.phar, you need to make the file executable and move it to somewhere in your PATH. For example:

$ chmod +x wp-cli.phar
$ sudo mv wp-cli.phar /usr/local/bin/wp

5. Intall tab completion for wp-cli:

$ wget https://github.com/wp-cli/wp-cli/raw/master/utils/wp-completion.bash
$ source wp-completion.bash


Now, I can reset my wordpress admin's password simply by:

1. Go to wordpress root folder:

$ cd /var/www

2. List users, check out the ID of my user:

$ wp user list

3. Reset my user's password:

$ wp user update 1 --user_pass=MyPassword

(1 is my user's ID)


For more commands of wp-cli, please read: http://wp-cli.org/commands/

Note: wp-cli will not work if your wordpress installation using APC object cache.

Comments