views:

235

answers:

4

I use the pylons and sqlalchemy. I constantly update the schema files and delete the old db content (means db itself) and recreate the database so that new schema shall take place. Every time I do this by opening the MySql Query Browser and login & delete the database/schema.

How to delete the mysql db/schema thorough linux shell commands? I use ubuntu linux.

+5  A: 
mysqladmin -u[username] -p[password] drop [database]
Alex Reisner
thanks Alex. I added -f to force the delete
Gopalakrishnan Subramani
Your password will be accessible to any other user on the system. `ps aux`. Consider using a `.my.cnf` instead.
gahooa
A: 

Another suitable way:

$ mysql -u you -p
<enter password>

>>> DROP DATABASE foo;
gahooa
That's basically the same as what he's been doing.
Scottie T
Illustrating the possiblities on the command line does not warrant a down vote. He was using MySql Query Browser. Not quite the same.
gahooa
+2  A: 

If you are tired of typing your password, create a (chmod 600) file ~/.my.cnf, and put in it:

[client]
user = "you"
password = "your-password"

For the sake of conversation:

echo 'DROP DATABASE foo;' | mysql
gahooa
although it is development environment, I really not much worried about password visible to others. I like your .my.cnf idea very much. +1 on the idea
Gopalakrishnan Subramani
+1  A: 

In general, you can pass any query to mysql from shell with -e option.

mysql -u username -ppassword -D dbname -e "DROP DATABASE" > outputfile.txt
Yada
Your password will be accessible to any other user on the system. `ps aux`. Consider using a `.my.cnf` instead.
gahooa