Documentation Home
MySQL Utilities 1.5 Manual
Related Documentation Download this Manual
PDF (US Ltr) - 1.0Mb
PDF (A4) - 1.0Mb
HTML Download (TGZ) - 192.4Kb
HTML Download (Zip) - 203.7Kb


MySQL Utilities 1.5 Manual  /  ...  /  Use login-paths (.mylogin.cnf)

2.2.1.1 Use login-paths (.mylogin.cnf)

The best way to specify server connection information is with your .mylogin.cnf file. Not only is this file encrypted, but any logging of the utility execution does not expose the connection information. Thus, no user names, passwords, ports, etc. are visible in the log. This is the preferred method for using MySQL Utilities to connect to servers.

Utilities support the use of login-paths in the connection string provided they use the following format login-path-name[:port][:socket] where the port and socket parameters are optional. If used, these optional parameters override the respective options from the specified login-path file.

When using login-paths, there are no default values except on Posix systems when specifying a socket. In this case, the host option defaults to localhost on port 3306. This means that combining the values specified in the login-path with the two optional values port and socket, one needs to specify at least a user, a hostname and a port or socket.

Use the mysql_config_editor tool (http://dev.mysql.com/doc/en/mysql-config-editor.html) to add the connection information as follows.

shell> mysql_config_editor set --login-path=instance_13001 --host=localhost --user=root --port=13001 --password
Enter password: <Password is prompted to be inserted in a more secure way>

Next, use the following command to confirm that the login-path data was correctly added to .mylogin.cnf (the encrypted file):

shell> mysql_config_editor print --login-path=instance_13001
[instance_13001]
user = root
password = *****
host = localhost
port = 13001

Once your .mylogin.cnf file is configured, you need only specify the section of the .mylogin.cnf file for the server connection. For example, the section created in the previous example is 'instance_13001'. Thus, we use --server=instance_13001. The following shows the execution of a utility specifying the login-path section.

shell> mysqlserverinfo --server=instance_13001 --format=vertical

# Source on localhost: ... connected.
*************************       1. row *************************
server: localhost:13001
config_file: /etc/my.cnf, /etc/mysql/my.cnf
binary_log: clone-bin.000001
binary_log_pos: 341
relay_log:
relay_log_pos:
version: 5.6.17-log
datadir: /Volumes/Source/source/temp_13001/
basedir: /Volumes/Source/source/git/mysql-5.6
plugin_dir: /Volumes/Source/source/git/mysql-5.6/lib/plugin/
general_log: OFF
general_log_file:
general_log_file_size:
log_error:
log_error_file_size:
slow_query_log: OFF
slow_query_log_file:
slow_query_log_file_size:
1 row.
#...done.

See the online MySQL Reference Manual for more information about login-paths, the .mylogin.cnf file, and the mysql_config_editor client.

Note

If you have an installation where the MySQL Server version is older (before 5.6.25 or 5.7.8) and my_print_defaults is newer, then the Utilities cannot access the passwords in the .login-path file because the newer versions of my_print_defaults mask the passwords, but older versions do not.


User Comments
Sign Up Login You must be logged in to post a comment.