WP-CLI is available on your hosting: it allows you to update WordPress, manage plugins, users, or the database with a single command, without going through the administration interface.
In short: connect via SSH, go to the directory where WordPress is installed and run wp --info: if the command responds, WP-CLI is ready. To change the site address, use wp search-replace, always with --dry-run first.
Prerequisites
How do I get started with WP-CLI?
Connect via SSH, then navigate to the directory where WordPress is installed: WP-CLI always works on the site in the current directory:
cd ~/exemple.ch
wp --info
If the command responds, everything is set up.
The most useful commands
Updates
wp core check-update # y a-t-il une mise à jour de WordPress ?
wp core update # mettre à jour le cœur
wp plugin update --all # mettre à jour toutes les extensions
wp theme update --all # mettre à jour tous les thèmes
wp core update-db # migrer la base après une mise à jour
Plugins and themes
wp plugin list
wp plugin install akismet --activate
wp plugin deactivate mon-extension
wp theme list
Users
wp user list
wp user create jean jean@exemple.ch --role=author
wp user update 12 --user_pass='nouveau-mot-de-passe'
wp user update is the fastest way to regain control of a site if you have lost the administrator password.
Database
wp db export sauvegarde.sql # exporter
wp db import sauvegarde.sql # réimporter
wp db check # vérifier
wp db repair # réparer
Options and cache
wp option get siteurl
wp option update blogname "Mon nouveau nom de site"
wp cache flush
How do I change the site address?
This is the most frequent use case, and the most risky, as the address is repeated in serialized data throughout the database. WP-CLI knows how to rewrite them correctly, whereas a simple SQL "search and replace" would break the site.
Always perform a dry run first. The --dry-run option displays what would be replaced, without modifying anything. And export the database before the actual operation: wp db export avant-remplacement.sql.
wp search-replace 'https://ancien-domaine.ch' 'https://nouveau-domaine.ch' --dry-run
wp search-replace 'https://ancien-domaine.ch' 'https://nouveau-domaine.ch'
How do I diagnose a broken site?
wp plugin deactivate --all # neutraliser toutes les extensions
wp theme activate twentytwentyfour
wp core verify-checksums # comparer les fichiers du cœur à l'original
wp core verify-checksums compares your WordPress files with those published by the project: any discrepancy indicates a modified or added file. This is a good first step after an infection. See Clean up a WordPress site after a hack.
How do I get help on commands?
Each command has its own built-in help:
wp help
wp help plugin install
The full documentation is available on wp-cli.org.
Going further