GoDaddy Ajuda

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 find and replace in the database.

Warning: You should make a backup of your database before making any changes. (Linux Hosting with cPanel / Windows Hosting with Plesk / VPS or Dedicated servers)
  1. Connect to your 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 when you exported the WordPress database

    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 find 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 find 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.

Related steps

More info