Post History
That's my Bash script: #!bin/sh cd qpixel sudo systemctl enable mysql mysql -u root -p rails s When it executes the line mysql -u root -p it will ask for password. To do so, I have tried...
#2: Post edited
How to give password in shell script?
- ```bash
- #!bin/sh
cd qpixelsudo systemctl enable mysqlmysql -u root -prails s- ```
That's my bash script. When it will run `mysql -u root -p` it will ask for password. So, I have to print my password. But, I had tried with `echo` `print` none of them works. How can I input password?- <s>[Related question](https://stackoverflow.com/questions/9358509/how-to-give-password-in-shell-script#9358547) I found in SO. </s> Answers of SO didn't help me either.
- That's my Bash script:
- ```bash
- #!bin/sh
- cd qpixel
- sudo systemctl enable mysql
- mysql -u root -p
- rails s
- ```
- When it executes the line `mysql -u root -p` it will ask for password. To do so, I have tried with `echo` and `print`, but none of them works.
- How can I input a password?
- <s>[Related question](https://stackoverflow.com/questions/9358509/how-to-give-password-in-shell-script#9358547) I found in SO. </s> Answers of SO didn't help me either.
#1: Initial revision
How to give password in shell script?
```bash #!bin/sh cd qpixel sudo systemctl enable mysql mysql -u root -p rails s ``` That's my bash script. When it will run `mysql -u root -p` it will ask for password. So, I have to print my password. But, I had tried with `echo` `print` none of them works. How can I input password? <s>[Related question](https://stackoverflow.com/questions/9358509/how-to-give-password-in-shell-script#9358547) I found in SO. </s> Answers of SO didn't help me either.