I have a server running MySQL 5.7.42 on Ubuntu Linux. I have a config file in
~/.my.cnf containing login info to connect to it from a shell on the same server:
[client] host = localhost user = root password = myPassword
The MySQL server is set to read from the default locations, which includes
mysqld --help --verbose 2>1 | grep "my.cnf" /etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf
and the client is set to do the same:
mysql --help --verbose 2>1 | grep "my.cnf" /etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf
/etc/my.cnf doesn't exist,
/etc/mysql/my.cnf contains only
[mysql], and there are no
client sections in anything in
But when I run
mysql, it fails, saying:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
but if I run
mysql --defaults-file=/.my.cnf, it connects successfully, telling me:
- the file is readable by the user I'm running the command as
- it is valid
- the credentials work.
I have the same style config file, in the same place, with the same ownership and permissions on several other servers and they all work fine.
Why isn't MySQL reading my config file?