Timeline for How to pass password to mysql command line
Current License: CC BY-SA 3.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 15, 2022 at 1:04 | comment | added | mFlorin |
defaults-extra-file didn't worked for me, but defaults-file worked ok. Thx, solved my problem (not wanting to put secrets in cmd).
|
|
| Jun 3, 2021 at 13:46 | comment | added | Mladen Jablanović | @DavidTonhofer this should be an answer on its own. | |
| Jun 16, 2019 at 21:05 | comment | added | vinkomlacic | The --defaults-extra-file must be the first option when executing the mentioned command. For me, it didn't work otherwise. | |
| Mar 21, 2018 at 6:51 | vote | accept | Kokizzu | ||
| Mar 1, 2018 at 18:02 | comment | added | David Tonhofer |
Set MYSQL_PWD in the environment (export MYSQL_PWD=muhpassword) and execute your command without the -p. See MySQL Program Environment Variables. In spite of the manual's dire warnings, this is rather safe. Unless you start weird warez in the same shell later. So we run: MYSQL_PWD=$(cat foo.php etc) mysql -u foouser -h barhost
|
|
| Feb 3, 2018 at 1:50 | comment | added | Geoffrey Wiseman |
Might be worth adding a note about --login-path now that it's supported. It's not much better than this, but it is slightly less plain-text (even though the barrier to converting the contents to plaintext is low).
|
|
| Oct 19, 2017 at 5:01 | comment | added | Wildcard | @Kusalananda, yes, but as per comments on unix.stackexchange.com/q/385339/135943, that does not mean it's safe! | |
| Feb 1, 2017 at 0:52 | comment | added | ChuckCottrill | This is the best solution, as it provides a measure of security. You need to chmod go-rwx, and make sure this argument preceeds all other arguments. | |
| Jan 23, 2017 at 13:40 | comment | added | Kusalananda♦ |
MySQL will modify its argv to overwrite the parameters given to the -p flag. At least that's what's concluded here, together with other relevant info: unix.stackexchange.com/questions/78757/…
|
|
| May 23, 2015 at 5:48 | history | answered | garethTheRed | CC BY-SA 3.0 |