Is there a way to pass the DB user password into the command line tool mysqladmin?

后端 未结 3 2001
情歌与酒
情歌与酒 2021-01-30 10:07

I currently use the following but it ALWAYS prompts me to manually type the password. Is there any way to pass it in on the command line when launching the executable?



        
相关标签:
3条回答
  • 2021-01-30 10:24

    Just found out the answer....

    mysqladmin processlist -u root -pYOURPASSWORDHERE
    

    No space between your password and the -p

    0 讨论(0)
  • 2021-01-30 10:38

    Try:

    --password=PasswordTextHere 
    
    0 讨论(0)
  • 2021-01-30 10:43

    This should work: mysql -uroot -p'password'

    If you're trying to automate mysql solution, you can use password from variable:

    mysql_pass=$(sudo grep -oP "temporary password is generated for root@localhost: \K(.*)" /var/log/mysqld.log)

    mysql -uroot -p"$mysql_pass" < somescript.sql

    0 讨论(0)
提交回复
热议问题