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.

이 글이 도움되었나요?
피드백을 보내주셔서 감사합니다. 고객 서비스 담당자에게 문의하시려면 지원 전화 번호 또는 위의 채팅 옵션을 이용하시기 바랍니다.
도와드릴 수 있어 기쁩니다! 더 도와 드릴 것이 있나요?
그것 유감스럽습니다. 혼동이 되었던 사항 또는 솔루션이 고객님의 문제를 해결하지 못했던 원인을 알려주세요.