List of useful CLI commands - Raruto/wordpress-git GitHub Wiki
Quick start
- run
wp core downloadto install wordpress (or even betterwp core install) - run
composer installto install any required plugins/themes (composer updateit's also fine).
WP CLI
To update:
- “Wordpress”:
wp update core
Solving common issues:
- “Another update is currently in progress”:
wp option delete core_updater.lock
MySQL Server
1. Connect to Server:
- for a MAMP installation use:
mysql --host=127.0.0.1 -uroot -proot
2. Show saved DBs:
SHOW DATABASES;
3. Create a new DB:
CREATE DATABASE my_new_db_name;(to delete a DB:DROP DATABASE my_db_name;)
4. Exit:
exit;
The short way (MAMP)
mysql --host=127.0.0.1 -uroot -proot -e "CREATE DATABASE my_new_db_name;";
All in One WP Migration (WP CLI Plugin)
Install the plugin
wp plugin install all-in-one-wp-migration --activate (You must reload the page once before continuing)
Do a backup (DB only)
wp ai1wm backup --exclude-media --exclude-themes --exclude-inactive-themes --exclude-muplugins --exclude-plugins --exclude-inactive-plugins --exclude-cache
Suggested: use "rsync" to sync media files.
Restore a backup
-
cd wp-content/ai1wm-backups/(go to backup directory) ormkdir wp-content/ai1wm-backups/(create if does not exist) -
wget http://example.com/wp-content/ai1wm-backups/backup-name.wpress(download the backup) -
wp ai1wm restore backup-name.wpress(restore from the backup)Remember: backup file must be located in the "ai1wm-backups" directory.
-
wp rewrite flush(flush permalinks, do it once or twice if you encounter problems) -
rm backup-name.wpress(remember to delete the backup file from the source as well)