DEV Community


Discussion on: How to securely login to MySQL without providing password each time

bobbyiliev profile image
Bobby Iliev Author

Hi there 👋,

Very good question.

Yes, this is doable, you can specify a host and then have a suffix for each host in your config file.


  • DB Host 1:
Enter fullscreen mode Exit fullscreen mode

Note the client + db1 suffix, then to specify which SQL server you would like to connect to you need to use the --defaults-group-suffix= flag, for the above example it will look like this:

mysql --defaults-group-suffix=db1
Enter fullscreen mode Exit fullscreen mode

To make things easier, you could also add a Bash alias for that command so that you don't have to type the whole thing each time.

Hope that this helps!

darshitpp profile image
Darshit Patel

Thanks for the reply! I will try this out