Replacing string in custom CMS database

Post Reply
User avatar
isscbta
Team Member
Posts: 137
Joined: Mon Jul 19, 2021 1:41 am
Has thanked: 17 times
Been thanked: 3 times

In situation when you need to replace some string in some custom CMS, and there is no easy-way to do that trough that CMS. This could be useful

In your SSH, as root, run:

Code: Select all

cd /root
git clone https://github.com/interconnectit/Search-Replace-DB.git

cd /home/someuser/web/domain.com/public_html

DATABASE_NAME=''
DATABASE_USERNAME=''
DATABASE_PASSWORD=''
REPLACE_FROM=''
REPLACE_TO=''
php /root/Search-Replace-DB/srdb.cli.php -h localhost -n "$DATABASE_NAME" -u "$DATABASE_USERNAME" -p "$DATABASE_PASSWORD" -s "$REPLACE_FROM" -r "$REPLACE_TO"
grep -rl "$REPLACE_FROM" ./ | xargs sed -i "s#$REPLACE_FROM#$REPLACE_TO#g"

Tags:
Post Reply