Hello,
The title says it all: MySQL is not using the hostname, user, and password that I have specified in my MySQL configuration file (my.cnf).
I have a my.cnf file located at /etc/mysql and a .my.cnf file at ~/.
The file in my ~ direcotry contains the following:
[client]
host = localhost
user = root
password = *****
In my php script, I have the following:
try
{
$pdo = new PDO('mysql:dbname=grad');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->exec('SET NAMES "utf8"');
}
catch (PDOException $e)
{
echo $e;
exit();
}
When I run mysql --print-defaults I can see that MySQL has indeed loaded the host, user and password from my config file, but it does not seem to take effect as my php script gives me the following error:
exception 'PDOException' with message 'SQLSTATE[42000] [1044] Access denied for user ''@'localhost' to database 'grad'' in /var/www/ ...
MySQL version: 5.5.29-0ubuntu0.12.04.1
Web server: Apache 2.2.22 (Ubuntu)
Any suggestions?
Thanks!