0

Been working all day on this one.. when i request the table it gives me the entire data base..

#!/bin/bash # mysqldump --user root --password=mypw sellnjho_realpro wp_posts > atest.sql mysqldump sellnjho_realpro wp_posts > atest.sql echo "All Done." 

Whether i add the table wp_posts or not it pulls the entire db I included the line with pw too in case that helps but the next line gives me the sql in full w/o the use of user or pw..

I tried user and pass to see and it failed all together telling me that using the user/pass on the command line was dangerous..

4
  • This is a question about the mysqldump command explicitly, not about shell in general (mysqldump is part of MySQL, not part of the shell); I'm updating the title and tags appropriately. BTW, what's with all the backticks? Did you add them as formatting, or are they really there in your actual script? Commented Apr 23, 2017 at 19:38
  • ...to be entirely explicit -- if they're part of your script, the backticks are wrong. For instance, $(echo "All done.") -- or the version with backticks in place of $() -- tries to run All Done. as a command, which fails for obvious reasons. And if they're part of your question's formatting, they're unnecessary -- the code formatting done by the {} button (or the four-space indents it creates) is sufficient. Commented Apr 23, 2017 at 19:42
  • Thanks for that but i was just copying the example they gave with the quotes not backtics.. and it seems to work fine and prints out done as it should thru out the program.. A little more detail.. when i use mysqldump and the dbname and table it does single out the table and exports that.. but when i try to add table to the import using mysql and no table it does put the table it exported into the correct table just fine.. so guess i am ok but thanks for the helping hand. Commented Apr 24, 2017 at 2:45
  • I'm a little clear about what you meant by your comment above, but if the output of echo is correctly printed, then clearly the backticks aren't really part of your code as you're running it, so I've edited them out of the question. Commented Apr 24, 2017 at 16:03

1 Answer 1

1

For pulling data of a single table using mysqldump command, you can use following command -

mysqldump --user [username] --password [password] --host [hostname] --databases [db_name] --tables [table_name] --lock-tables > file.sql 

In your case,

mysqldump --user root --password mypw --databases sellnjho_realpro --tables wp_posts --lock-tables > wp_posts.sql 

Refer this link for more information on mysqldump

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.