Created
July 20, 2012 09:12
-
-
Save daogurtsov/3149766 to your computer and use it in GitHub Desktop.
wp create databases
This file contains hidden or 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/sh | |
#Start vars declaration | |
#default domains.txt format used as input file: | |
#domain_name database_name user_name password hosting_url | |
dbList=domains.txt | |
createLog=logs/create_log.txt | |
rootUser="root" | |
rootPass="win7" | |
#on some vds set user@"%" | |
rootHost="localhost" | |
#End vars declaration | |
if [ -f "$dbList" ]; then | |
if [ -f "$createLog" ]; then | |
rm "$createLog" | |
fi | |
touch "$createLog" | |
while read db_file_name db_name db_user db_pass db_host | |
do | |
query="CREATE USER '$db_user'@'$rootHost' IDENTIFIED BY '$db_pass'" | |
mysql -u "$rootUser" --password="$rootPass" -h "$rootHost" -e "$query" | |
query="CREATE DATABASE $db_name CHARACTER SET utf8 COLLATE utf8_bin" | |
mysql -u "$rootUser" --password="$rootPass" -h "$rootHost" -e "$query" | |
query="GRANT ALL PRIVILEGES ON $db_name.* TO $db_name@$rootHost" | |
mysql -u "$rootUser" --password="$rootPass" -h "$rootHost" -e "$query" | |
date=`date` | |
echo "$db_file_name $date" >> "$createLog" | |
done < "$dbList" | |
cat "$createLog" | |
echo "===============" | |
wc -l "$createLog" | |
fi | |
echo "==============" | |
echo "CREATION FINISHED" | |
echo "==============" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment