Last active
July 20, 2018 07:56
-
-
Save thomasfr/c68f634b853bba570aeb 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