0

this is an example but its not working. The file name is "mysql_login.sh"

#!/bin/bash
login_sql=" --login-path=local "
echo -e "PASSQORD345\n" | sudo -S mysql $login_sql $1

my motto is when i will run the file "$sh mysql_login.sh db_name" from command line then it will log in to mysql and use the db db_name.

currently i need to log in as root with root pas then its working but i want , i will just run the sh file then it will log in as root with root password and will log in in mysql server.

Error getting : ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Samiul
  • 485
  • 3
  • 7
  • 15
  • Does this answer your question? [Use sudo with password as parameter](https://stackoverflow.com/questions/11955298/use-sudo-with-password-as-parameter) What is your question exactly? Note `sudo su root | mysql` does not make much sense - it redirects output of `sudo` command to `mysql`. – KamilCuk Mar 05 '20 at 15:03
  • i am getting an error :ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) – Samiul Mar 05 '20 at 15:09

0 Answers0