I can connect to mysql using the following line:
mysql -u myusername -p
(enters password into terminal)
>>>Welcome to the MySQL monitor. Commands end with ; or \g.
>>>Your MySQL connection id is 51
>>>Server version: 5.6.10-log Source distribution
Here is my .my.cnf in my home directory (not /etc/my.cnf):
[client]
user = myusername
password = mypassword
host = localhost
There also appears to be a client section in my /etc/my.cnf:
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
However when I just type "mysql" into the terminal, I get:
ERROR 1045 (28000): Access denied for user 'myusername'@'localhost' (using password: YES)
What is wrong with my my.cnf?
ALso, it has nothing to do with anon user as mentioned here: MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)
Here is the result of a suggested query:
>>>mysql --print-defaults
>>>mysql would have been started with the following arguments:
>>>--port=3306 --socket=/tmp/mysql.sock --no-auto-rehash --user=myusername --password=mypassword --host=localhost
As @Wrikken said in the comments, it will work if you quote your password and the password contains characters such as =
or ;
.
Your problem is that you are missing the quotes around the password.
[client]
user = myusername
password = "mypassword"
host = localhost
http://dev.mysql.com/doc/refman/5.7/en/option-files.html
Search for "Here is a typical user option file:" and see the example they state in there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With