1
Let’s say we have password stored in /root/mysql-password
. Is there a way to connect to MySQL without manually coping password from that file and entering to mysql -u root -p{passowrd}
?
For example something like this:
mysql -u root -p | {command} /root/mysql-password
Thanks for the answer. So this is the only way? And there is no common "linux way" to do such things? – RuslanN – 2015-10-16T13:13:46.637
Sorry, I'm not sure I understand exactly what you are asking. In Linux, you generally either have credentials in a flat config file (e.g. .my.cnf), a hashed or encrypted file, environment variables, through ssh keys, or a password prompt. Passing the password through the command directly is very insecure. Are you doing something where the defaults-file or .my.cnf doesn't work for you? – Bryan – 2015-11-09T00:21:12.007
My password is in a file and whenever I wanted to connect to mysql I had to to "cat file/with/password" copy it and "mysql -u user -ppassword" I thought it is possible to automate manual coping part – RuslanN – 2015-11-10T02:53:20.553