2

I have multiple MySQL databases(50+) and I want to replace a string in all of them, is there anyway to search and replace in all the databases?

Server is CentOS and I have SSH root access.

Arulkumar
1,1379 silver badges25 bronze badges
asked Jan 28, 2016 at 0:20

1 Answer 1

0

Not really.

Instead, you could do something like

SELECT CONCAT("UPDATE ", table_schema, ".", table_name, 
 " SET foo = replace(foo, 'this', 'that');")
 FROM information_schema.tables
 WHERE ...

to generate the desired 50+ UPDATE statements. Then copy and paste them into the mysql commandline tool.

(Or you could construct a shell script using that. Or...)

answered Jan 28, 2016 at 0:24

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.