0

good day . I need some help please about code on how can i create a batch file that export mysql database by table.

FOR %%D IN `mysql -uroot -e "SHOW TABLES from sample"` do echo %%D mysqldump -uroot sample %%D > %%D.sql

help. thank you.

1
  • Sir. this is my code @echo off SET path=C:\Users\neca\Desktop cd C:\wamp\bin\mysql\mysql5.5.24\bin FOR /F "tokens=*" %%D IN ('mysql -uroot -e "SHOW TABLES from sample"') do echo %%D pause BUT in my db I only have 2 tables (sample and test). Why is it that the output of this code is Tables_in_sample sample test where Tables_in_sample is a table that i did not made. Commented Feb 9, 2015 at 1:45

1 Answer 1

1

Start with next command:

FOR /F "tokens=*" %%D IN ('mysql -uroot -e "SHOW TABLES from sample"') do @echo %%D

Then you could refine and modify output with some %%~D modifiers.

Next resource on for /F command.

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

5 Comments

sir. what does "tokens=* mean? what should i pud? thank you for your responds.
@JosefZ - You missed the closing " on the tokens section. @xXxrk04 - "tokens=*" means proces the entire line and ignore any delimiters. He could also have used "delims=" - it's just personal preference.
Mea culpa, mea maxima culpa! Thank you, @SomethingDark (and being a habitual paranoid one could use both "tokens=* delims=" as well :))
Sir. this is my code @echo off SET path=C:\Users\neca\Desktop cd C:\wamp\bin\mysql\mysql5.5.24\bin FOR /F "tokens=*" %%D IN ('mysql -uroot -e "SHOW TABLES from sample"') do echo %%D pause BUT in my db only have 2 table sample and test. why is it that the output of this code is Tables_in_sample sample test where Tables_in_sample is a table that i did not made.
Sir. this is my code @echo off SET path=C:\Users\neca\Desktop cd C:\wamp\bin\mysql\mysql5.5.24\bin FOR /F "tokens=*" %%D IN ('mysql -uroot -e "SHOW TABLES from sample"') do echo %%D pause BUT in my db I only have 2 tables (sample and test). Why is it that the output of this code is Tables_in_sample sample test where Tables_in_sample is a table that i did not made.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.