Knowledgebase

Using WP-CLI for Database Work Print

  • databasesphpmyadmin, databases, wordpress, database, password, phpmyadmin, performance, support
  • 0

The command line tool for WordPress.

WHAT IT IS

A command-line interface to WordPress, available where you have SSH access.

WHY IT IS BETTER THAN PHPMYADMIN FOR SOME TASKS

It understands WordPress, so it handles serialised data and related records correctly.

It has no execution time limit.

USEFUL DATABASE COMMANDS

Exporting the database to a file Importing a dump Running a search and replace that handles serialisation correctly Resetting a user password Checking and repairing tables Optimising tables

THE SEARCH AND REPLACE

The single most valuable command. It handles serialised data properly, which is exactly where a plain SQL replace fails.

It also has a dry run option showing what would change before changing it.

Use that first, always.

RESETTING A PASSWORD

One command, handled correctly, rather than editing the users table by hand.

GETTING IT

Check whether SSH is available on your plan. If it is, WP-CLI may already be installed.

Open a ticket and ask.

WHY IT IS WORTH LEARNING

The commands most people need are few, and they are considerably safer than the manual equivalents.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot