How to create a database from shell command?

koszikot picture koszikot · Mar 11, 2010 · Viewed 234.5k times · Source

I'm looking for something like createdb in PostgreSQL or any other solution that would allow me to create database with a help of a shell command. Any hints?

Answer

Felix Kling picture Felix Kling · Mar 11, 2010

You mean while the mysql environment?

create database testdb;

Or directly from command line:

mysql -u root -e "create database testdb";