I used the above command and modified according to my requirement.
I needed to get passwords column from the wordpress mysql database in a text file , to do that i used the following below command
echo "select user_pass from wp_users"| mysql -uroot -proot wp_database > passwordList.txt