-
-
Save devsekhar/9a6af2a1c617da7b9186511d55cbe1e0 to your computer and use it in GitHub Desktop.
Execute a SQL Statement in many Databases of one mysql server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
user="${1}" | |
host="${2}" | |
like="${3}" | |
all_dbs="$(mysql -u $user -p -h "$host" -Bse 'SELECT SCHEMA_NAME from information_schema.SCHEMATA WHERE SCHEMA_NAME like "${like}"' 2> /dev/null)" | |
for db in $all_dbs | |
do | |
mysql -u $user -p -h "$host" $db -sN -e "SELECT * FROM centerdaten;" 2> /dev/null | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment