On Linux, my.cnf can be altered such that mysql -u myusername will work on the client side without the -p option. It's safer to use config files to set this up rather than putting the password in at the login line, and it's more convenient (though perhaps less safe) than putting the password in at the default -p prompt. But I have yet been able to find a guide on altering the my.ini file to achieve this result. For reference, I have been using: https://dev.mysql.com/doc/refman/5.7/en/option-files.html (my version is 5.7). I also have read the my.ini file. The language used is too ambiguous and technical for me to understand so I hope to find or eventually compose a real guide.
According to my research:
my.cnfalso works.- mysql will search for .cnf files at the locations specified in the
mysqldvlhelp.txtfile (which does not exist on Windows).
For example on Windows, you can set only the password
bananaunder[client]inmy.inias shown below. *My answer explains[client]and my answer explains wheremy.iniis located on Windows and my answer explains how to log in by setting both the userjohnand the passwordbananaunder[client]inmy.ini:Then, you can log in by setting
my.ini's location andjohnto--defaults-file=or--defaults-extra-file=and-urespectively as shown below. *--defaults-file=or--defaults-extra-file=must be the 1st option otherwise there is the error:Or:
*Not setting
my.ini's location to--defaults-file=or--defaults-extra-file=gets error as shown below: