Did you try connecting with 127.0.0.1 instead of through the socket?
The mysql cookbook installs a new instance of mysql that is not available through the standard socket. I notice that you specified what should be the correct socket, but who knows?
I also saw your later note on the problem related to /var/lib/mysql - maybe the there is a standard mysql instance lurking somewhere that accesses this directory, and the two instances are interfering with each other?
Kevin Keane
The NetTech
Our values: Privacy, Liberty, Justice
See https://www.4nettech.com/corp/the-nettech-values.html
-----Original message-----
From: Greg Barker fletch@fletchowns.net
Sent: Sunday 13th September 2015 4:30
To: chef@lists.opscode.com
Subject: [chef] Access denied error using mysql & database cookbooks
Can’t seem to figure out what is causing this error. I’ve been using this same cookbook for awhile and it seemed like it stopped working recently. I tried updating to the latest versions of the cookbooks and still encounter the issue.
Here’s my recipe:
mysql2_chef_gem “default” do
action :install
end
mysql_service “default” do
port "3306"
version "5.5"
initial_root_password "changeme"
action [:create, :start]
data_dir "/var/lib/mysql"
end
mysql_connection_info = {
:socket => “/run/mysql-default/mysqld.sock”,
:username => “root”,
:password => “changeme”
}
mysql_database “test_db” do
connection mysql_connection_info
action :create
end
This results in the following error:
[2015-09-13T11:23:01+00:00] ERROR: mysql_database[test_db] (fletchowns::mysql line 19) had an error: Mysql2::Error: Access denied for user ‘root’@‘localhost’ (using password: YES)
Here’s the output from the run: https://gist.github.com/fletchowns/66c13db76d20be182597
Base box is opscode_debian-7.8_chef-provisionerless.box
I tried to ssh into the machine but couldn’t seem to connect to mysql there either:
$ vagrant ssh
Linux packer-debian-7 3.2.0-4-amd64 #1 SMP Debian 3.2.65-1+deb7u1 x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
You have mail.
Last login: Sun Sep 13 11:13:20 2015 from 10.0.2.2
vagrant@default-debian-78:~ ps aux | grep mysql
root 17062 0.0 0.0 4184 728 ? S 11:14 0:00 /bin/sh /usr/bin/mysqld_safe --defaults-file=/etc/mysql-default/my.cnf
mysql 17236 0.1 1.9 330460 39956 ? Sl 11:14 0:00 /usr/sbin/mysqld --defaults-file=/etc/mysql-default/my.cnf --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql-default/error.log --pid-file=/run/mysql-default/mysqld.pid --socket=/run/mysql-default/mysqld.sock --port=3306
vagrant 17364 0.0 0.0 7836 876 pts/0 S+ 11:16 0:00 grep mysql
vagrant@default-debian-78:~ ls -la /run/mysql-default/mysqld.sock
srwxrwxrwx 1 mysql mysql 0 Sep 13 11:14 /run/mysql-default/mysqld.sock
vagrant@default-debian-78:~$ sudo su -
root@default-debian-78:~# mysql -u root -S /run/mysql-default/mysqld.sock -p
Enter password:
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)
root@default-debian-78:~#
Any help is greatly appreciated. Thanks!