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

MysqlWindowsWindows Server-2008Mysqladmin

Mysql Problem Overview


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

Mysql Solutions


Solution 1 - Mysql

Just found out the answer....

mysqladmin processlist -u root -pYOURPASSWORDHERE

No space between your password and the -p

Solution 2 - Mysql

Try:

--password=PasswordTextHere 

Solution 3 - Mysql

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEthan AllenView Question on Stackoverflow
Solution 1 - MysqlEthan AllenView Answer on Stackoverflow
Solution 2 - Mysqlge0manView Answer on Stackoverflow
Solution 3 - Mysql3lvinazView Answer on Stackoverflow