Create mysql database with bash script - confused

Hi, i have the following:

db="create database xxx;GRANT ALL PRIVILEGES ON xxx.* TO user@localhost IDENTIFIED BY 'password';FLUSH PRIVILEGES;quit;"
mysql -u root -p$mysql_pass -e "$db"

I don't understand why this is failing, it works fine when run from cmd but when is run in a bash script, mysql is giving me an error, something with incorrect syntax near 'quit'. I'm sure is something simple but I can't figure it out.

Thank you.

Just remove the last 'quit;'. it isn't needed and is redundant when you're executing a script that includes the -e.

Cheers,
Keith