Connecting to MySQL without entering the password using mysql_config_editor

Share via:

Dear Readers,

in this article , we will see, Connecting to MySQL without entering the password using mysql_config_editor

The mysql_config_editor utility enables you to store authentication credentials in an obfuscated login path file named.mylogin.cnf. The file location is the %APPDATA%\MySQL directory on Windows and the current user’s home directory on non-Windows systems. The file can be read later by MySQL client programs to obtain authentication credentials for connecting to MySQL Server.

Advantages and scenarios:

  • While using bash scripts you no need to save the passwords in a text file where everyone can view the password. Instead we can use this method so that passwords are safe
  • If you want to give temporary root access to a developer we can use this method so that the passwords are safe

 

Follow below steps :

1.Connect to MySQL and create a regular MySQL user and grant permissions

2.Use mysql_config_editior command and provide the password with a unique name.

Passwords should be in “”. Else you can’t connect

This will create a hidden file in the users home directory. I logged in with root. My home directory is root. This will be encrypted format and you can’t see any data in the file if we open the file

 

3.mysql_config_editor print –all to check if the login you created exists in the file

4.Connect to MySQL using mysql –login-path=mylogin.In this way you can hide the user name and the password

In any case if you change the mysql password for the user you need to update the same in config-editor. For this you need to remove and create again

 

mysql_config_editor –reset and again create from step 1

 

I hope above information is useful and helpful.

Thanks for reading ……………..

 

 

Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)
Loading...

Add Comment