I am totally new to the ssh so pardon if I commit any mistake. Well, I have had 457 databases which i wanted to take backup and put databases in individual files. Which i got a working solution from this Answer. Now I have dumped all the databases now i want to delete/drop all the databases from MySQL. I have googled alot but didn't find a useful resource to my question or maybe i am not aware of terms so truly seeking for help.

  • What does SSH have to do with this? – womble Jun 26 '18 at 2:21
  • Actually, i have shared web hosting from Bluehost and they blocked my access to PhpMyAdmin now the only way i have to use ssh to backup all of my databases and then delete it. The dumping part is done but deletion part is remaining – Aitazaz Khan Jun 26 '18 at 2:23

You will need the command DROP DATABASE database_name and need to do this for all databases. I do not think there is one command that will delete all databases at once.

You may try this while loop:

echo "show databases;" | mysql -u <username> -p <password>|while read databasename 
     do echo deleting $databasename
     drop database $databasename 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.