To install WordPress from the command line there are several tools available WordShell (commercial) and wp-cli (free)to name a few – but here I will show you how you can use the basic command line or shell to speed up things.
We do a full WordPress installation from the command line we will use the command line to download the latest WordPress version, untar it(decompress the archive) and remove the WordPress folder using typical *Nix commands.
https://gist.github.com/4640125
You can also add a new database using the shell. See here the command to import database data:
https://gist.github.com/4529189
To create a new database you will need to log into the MySQL client and then create one.
mysql -u root -p CREATE DATABASE dbasename;
Could be you need to type mysql5 instead of mysql, but the rest should be the same. You then need to grant privileges to the database for a user of choice:
GRANT ALL PRIVILEGES ON dbasename.* TO user@host IDENTIFIED BY 'user_pass';