Reputation: 4128
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.cnf
also works.mysqldvlhelp.txt
file (which does not exist on Windows).Upvotes: 1
Views: 590
Reputation: 1
For example on Windows, you can set only the password banana
under [client]
in my.ini
as shown below. *My answer explains [client]
and my answer explains where my.ini
is located on Windows and my answer explains how to log in by setting both the user john
and the password banana
under [client]
in my.ini
:
# "my.ini"
[client]
password="banana"
Then, you can log in by setting my.ini
's location and john
to --defaults-file=
or --defaults-extra-file=
and -u
respectively as shown below. *--defaults-file=
or --defaults-extra-file=
must be the 1st option otherwise there is the error:
mysql --defaults-file='C:\ProgramData\MySQL\MySQL Server 8.0\my.ini' -u john
Or:
mysql --defaults-extra-file='C:\ProgramData\MySQL\MySQL Server 8.0\my.ini' -u john
*Not setting my.ini
's location to --defaults-file=
or --defaults-extra-file=
gets error as shown below:
mysql -u john
ERROR 1045 (28000): Access denied for user 'john'@'localhost' (using password: NO)
Upvotes: 0
Reputation:
In your my.ini, you can create a client section to put the user and password.
[client]
user=yourmysqluserhere
password=yourpasswordhere
Upvotes: 0