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.
Prerequisites: SSH access must be enabled for your hosting. See Connecting to your account via SSH.
Getting started
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
Changing 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'
Diagnosing 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 Cleanup after a hack.
Going further
Each command has its own built-in help:
wp help
wp help plugin install
La documentation complète est disponible sur wp-cli.org.