Is it possible to save the password in .my.cnf or similiar on Windows for mysql?
2 Answers
Yes , it is possible.
I posted something similar on StackOverflow.
On your my.cnf
file create a [client]
session , in my case it was on /etc/mysql/my.cnf
.
root@ergesttstsrv:~# cat /etc/mysql/my.cnf
[client]
host=localhost
user=root
password=*********
#database=gesti
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
Uncomment #database=gesti
if you want to use a default login database.
Restart MySQL service
root@ergesttstsrv:~# service mysql restart
root@ergesttstsrv:~# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.25 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select current_user();
+----------------+
| current_user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)
https://dev.mysql.com/doc/refman/8.0/en/mysql-config-editor.html
mysql_config_editor
is a convenient tool for hiding login credentials. On *nix, I use it plus an alias
so I can log into a variety of servers and databases with a simple command. (I don't know if Windows has the equivalent of alias
.)