eZ Publish: How to quicly change the database name in all siteaccesses
Suppose you are in the following situation:
- you have an eZ Publish installation that have many siteaccesses that uses their own database and
- the databases have similar names (starting with a given prefix) and
- you have upgraded it (or for any reason) and now you have a new set of databases with a new prefix and must change the Database setting in all site.ini.append.php in all siteaccesses
then, on Linux, you can use the following command to change the database name in all the files very quickly.
# for i in `find settings/siteaccess/ -name *.ini.append.php`; do sed -i 's/Database=<your-db-prefix>/Database=<your-new-db-prefix>/' $i; done
Note: the "find settings ..." text is enclosed in the "backquotes", do not confuse the char with the single quote (` is not ' ); this is important, as the backquoted string is interpreted as a subcomand, the shell will take that string and execute the command inside it and put the result back.
So, the command can be readed like: for each file in 'files under the settings/siteaccess/ folder and its subfolders whos name ends in ".ini.append.php" replace the string "Database=<something> with string Database=<somethingelse>.
The command presupposes you are in the root folder of your eZ Publish installation.