Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- echo "Input database name"
- read databaseName
- echo "The database name is set to $databaseName"
- echo "Input database host"
- read databaseHost
- echo "The database host is set to $databaseHost"
- echo "Input database user"
- read user
- echo "The database user is set to $user"
- stty -echo
- echo "Input database user password"
- read password
- stty echo
- echo "Input url to search for"
- read searchUrl
- echo "The search url is set to $searchUrl"
- echo "Input url to replace with the searched url"
- read replaceUrl
- echo "The replace url is set to $replaceUrl"
- mysql --user="$user" --password="$password" --host="$databaseHost" --database="$databaseName" -e "UPDATE messages SET message = REPLACE(message, '$searchUrl', '$replaceUrl')"
- read -p "Database name: " databaseName
- read -s -p "Database user: " password
- command=$(printf 'UPDATE messages SET message = REPLACE(message, %q, %q')
- "$searchUrl", "$replaceUrl")
- mysql --user="$user" --password
- --host="$databaseHost" --database="$databaseName"
- -e "$command"
- read -p "Input url to search for" searchUrl;
- read -p "Input url to replace with the searched url" replaceUrl;
- mysql --user="$user" --password --host="$databaseHost" --database="$databaseName"
- -e "PREPARE statement FROM 'UPDATE messages SET message = REPLACE(message, ?, ?)'; EXECUTE statement USING '$searchUrl','$replaceUrl';"
Add Comment
Please, Sign In to add comment