How to secure Login credentials in MySQL using mysql_config_editor (.mylogin.cnf.)

Use the mysql_config_editor to Secure the connection Information

mysql_config_editor set --login-path=MySQL57 --host=localhost --user=root --port=3306 --Password

Enter password: *******

Confirm that the login-path data was correctly added to .mylogin.cnf

mysql_config_editor print --login-path=MySQL57
mysql_config_editor print --all

user = root
password = *****
host = localhost
port = 3306

Connect to MySQL server using .mylogin.cnf.

mysql --login-path=MySQL57

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.18-log MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

The execution of a utility specifying the login-path section.

mysqlserverinfo --server=MySQL57 --format=vertical

# Source on localhost: ... connected.
*************************       1. row *************************
                   server: localhost:3306
              config_file: c:\my.ini
               binary_log: bin_log.000015
           binary_log_pos: 154
                  version: 5.7.18-log
                  datadir: C:\ProgramData\MySQL\MySQL Server 5.7\Data\
                  basedir: C:\Program Files (x86)\MySQL\MySQL Server 5.7\
               plugin_dir: C:\Program Files (x86)\MySQL\MySQL Server 5.7\lib\plugin\
              general_log: ON
         general_log_file: C:/mysql/general_log.log
    general_log_file_size: 3608472 bytes
                log_error: C:\mysql\mysql_log.log
      log_error_file_size: 122782 bytes
           slow_query_log: ON
      slow_query_log_file: C:/mysql/sql_log.log
 slow_query_log_file_size: 3105 bytes
1 row.

Where to find .mylogin.cnf. file ?

The file location is the %APPDATA%\MySQL directory on Windows and the current user's home directory on non-Windows Systems

No comments:

Post a Comment