I have a script to clone a vhost and associated db - however one of the mysql commands doesn't work. It fails and ends up outputting the mysql version number and 'how to use' info as if it hasn't been passed valid arguments - no error is given though.
An abbreviated version of the script is below - it's the line that should create the new database and grant privilidges that is failing. I'd appreciate any guidance on what I've got wrong or how to track down the problem.
#!/bin/bash -e clear echo "MySQL Admin Password: " read -s mysqlpass echo "New Site name (short, a-zA-Z only)" read -e newsitename echo "Last chance - sure you want to run the script? (y/n)" read -e run if [ "$run" == y ] ; then # This command doesn't work dbsetup="CREATE DATABASE "$newsitename"_db;GRANT ALL PRIVILEGES ON "$newsitename"_db.* TO 'site_usr'@'localhost';FLUSH PRIVILEGES;" mysql -u root -p$mysqlpass -e "$dbsetup" mysqldump -u root -p$mysqlpass template_db > temp.sql dbimport=$newsitename"_db < temp.sql" mysql -u root -p$mysqlpass $dbimport else exit fi