Create the .mylogin.cnf file using mysql_config_editor:
shell> mysql_config_editor set --login-path=dbadmin_local --host=localhost --user=dbadmin --passwordEnter password:
You can add multiple hostnames and passwords by changing the login path. If the password is changed, you can run this utility again, which updates the password in the file:
shell> mysql_config_editor set --login-path=dbadmin_remote --host=35.186.157.16 --user=dbadmin --passwordEnter password:
If you want to log in to 35.186.157.16 using the dbadmin user, you can simply execute mysql --login-path=dbadmin_remote:
shell> mysql --login-path=dbadmin_remote Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 215074~mysql> SELECT ...