For an example i would like to login to mysql with a password. i KNOW i can use -pmypass but i want to learn how do i redirect stdin in bash. So my test is
That's a bashism and echo solution is more common in scripts, though my solution can be more handy in an interactive shell (and I doubt any of these solutions works with mysql, but your question is more general).