I'm looking for something like createdb in psql or any other solution that would allow me to create databse with a help of a shell command. Any hints?
+1
A:
You can use SQL on the command line:
echo 'CREATE DATABASE dbname;' | mysql <...>
Or you can use mysqladmin
:
mysqladmin create dbname
Lukáš Lalinský
2010-03-11 20:26:41
+2
A:
You mean while the mysql environment?
create database testdb;
Or directly from command line:
mysql -u root -e "create database testdb";
Felix Kling
2010-03-11 20:27:50
mysql -u root -e "create database testdb"; Thats what i was looking for :) thank you
koszikot
2010-03-11 21:07:50
A:
cat filename.sql | mysql -u username -p
(type mysql password when asked for it.)
Where filename.sql holds all the sql to create your database. Or...
echo "create database databasename" | mysql -u -u username -p
if you really only want to create a database.
Kris
2010-03-11 20:29:26