2

I need to delete all the tables from my database name "marketing" for magento. I am a beginner so I don’t know much.

please help me , as I can not drop my database.

Thanks,

Divyang

4
  • 5
    possible duplicate of Truncate all tables in a MySQL database in one command? Commented Sep 18, 2015 at 6:27
  • you wanted to drop tables? or you want to delete records from all your DB database tables? Commented Sep 18, 2015 at 6:28
  • i have tried with " mysql -uroot -ppassword -Nse 'show tables' typo3_6 | while read table; do mysql -e "truncate table $table" typo3_6; done " as root is my user and password is my password . but got Access denied for user error. Commented Sep 18, 2015 at 6:37
  • @divyang , you can drop the tables. Commented Sep 18, 2015 at 8:59

1 Answer 1

1

You can use below single line command directly from linux server but first test on any testing environment before executing it for safe side.

mysql -uroot -p<pass> -Nse 'show tables' margeting | while read table; do mysql -uroot -p<pass> marketing -e "drop table $table"; done

If you want to do it manually then use below steps-

First get all tables-

show tables from margeting;

Now prepare drop command you can do it in excel etc like-

use marketing;
drop table mytable1;
drop table mytable2;

Now you can execute these statements from anywhere like from any query browser etc-

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks mysql -uroot -p<pass> -Nse 'show tables' margeting | while read table; do mysql -uroot -p<pass> marketing -e "drop table $table"; done works
if it helps you then you may accept it as answer by green tick. :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.