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

穿精又带淫゛_ 提交于 2019-12-29 11:40:12

问题


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?

mysqladmin processlist -u root -p

回答1:


Just found out the answer....

mysqladmin processlist -u root -pYOURPASSWORDHERE

No space between your password and the -p




回答2:


Try:

--password=PasswordTextHere 



回答3:


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



来源:https://stackoverflow.com/questions/12665522/is-there-a-way-to-pass-the-db-user-password-into-the-command-line-tool-mysqladmi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!