This is how I create a database stack and a directory for WordPress in my Ubuntu environment:
cat <<-DBSTACK | mysql -u root -p"${dbrootp}"
CREATE USER "${domain}"@"localhost" IDENTIFIED BY "${dbuserp}";
CREATE DATABASE "${domain}";
GRANT ALL PRIVILEGES ON ${domain}.* TO "${domain}"@"localhost";
DBSTACK
curl -L http://wordpress.org/latest.tar.gz | tar -zx -C ${domain}/
cp ${domain}/wp-config-sample.php ${domain}/wp-config.php
sed -ir "s/username_here|database_name_here/${domain}/g ; s/password_here/${dbuserp}/g" ${domain}"/ ${domain}/wp-config.php
Can this code be reduced to say, two lines of code with WP-CLI?