Tuesday, May 4, 2010

Drop database from DOS batch script


mysql -uroot -pabc123 -e "drop database netsight" >nul 2>1&

The option -e to run execute a command. --help (-?) to display help information.

Redirect to null to keep quiet. Otherwise, it may display an error "ERROR 1010 (HY000) at line 1: Error dropping database (can't rmdir '.\netsight', errno: 41)". Since when dropping a database, it will try to delete folder mysql/data/netsight, it fails if the folder contains some non-db files.

No comments: