Find and replace for WordPress with SSH

For experienced users, it can be more efficient to use SSH when managing WordPress, and performing tasks such as a search and replace in the database.

Warning: Make a backup of your database before making any changes. ( cPanel / Plesk / Web & Classic / VPS)
  1. Connect to your server or shared hosting account with SSH.
  2. Export your WordPress database.
  3. Open the dump file with the vim text editor with the following command:

    vim filename.sql

    Update the command with the following information:

    • filename.sql is the name of the dump file you just created

    Note: If your current working directory is different than your working directory at the time the dump file was created, then you will need to include the path to the file in the command. For example:

    vim /home/user/public_html/filename.sql

  4. Enter command mode by typing the colon (:) character.

  5. Once in command mode, execute a search and replace with the following command:

    %s/OldDomain/NewDomain/g

    Update the command with the following information:

    • OldDomain is your old domain or data
    • NewDomain if your new domain or data
  6. Press Enter to run the command, which will execute a search and replace of the old domain/data with the new domain/data.

  7. Press Esc to exit the insert/append mode.
  8. Type the following command to enter command mode, save the file and exit

    :wq
  9. Import your updated database using SSH.

Next steps

More info

More info about WPPS.

Var den här artikeln till hjälp?
Tack för din feedback. Ring vårt supportnummer eller starta chattalternativet ovan om du vill prata med en medarbetare på kundtjänst.
Vi är glada att vi kunde hjälpa till! Finns det något mer vi kan göra för dig?
Det var tråkigt att höra. Berätta vad som var krångligt eller varför lösningen inte hjälpte dig med problemet.