HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlModerate

How can I make MySQL client read password from mylogin.cnf?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
canreadmyloginmakecnfpasswordclientmysqlhowfrom

Problem

I'm trying to make the mysql client connect to a mysql server without requiring the password to be given interactively.
Steps taken:

1) First create a mylogin.cnf file

$ mysql_config_editor set --user= --password --host=
Enter password:


2) File created successfully:

$ ls -la .mylogin.cnf
-rw-------. 1 urmt urmt  136 Dec 19 11:01 .mylogin.cnf
$ mysql_config_editor print --all
[client]
user = 
password = *****
host = 


3) Connect using mysql client

$ mysql 
ERROR 1045 (28000): Access denied for user ''@'' (using password: NO)


Is there a default value/configuration somewhere that makes the client ignore the password in mylogin.cnf? The user and host properties were read correctly from the file.

I am able to connect just fine if I provide the password on the command line:

$ mysql -p 
Enter password: 
Reading table information...
...
mysql>


MySQL client version is 5.6.22, MySQL Server version is 5.6.22, both on Oracle Linux 6. Client and server are on different hosts.

Thanks

Solution

use following command to set login path first


mysql_config_editor set --login-path=lgpath --user=root -p

password

and then use below command to login mysql


mysql --login-path=lgpath

Help about mysql login path options can bee seen by


mysql_config_editor set --help

Context

StackExchange Database Administrators Q#86595, answer score: 15

Revisions (0)

No revisions yet.