Replacing string in custom CMS database
Posted: Tue Jan 31, 2023 1:16 pm
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:
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"