# MySql chef coookBook (Access Denied Error)

**URL:** <https://discourse.chef.io/t/mysql-chef-coookbook-access-denied-error/16005>\
**Category:** Chef Infra (archive)\
**Created:** [October 2, 2019, 6:26pm UTC](https://discourse.chef.io/t/mysql-chef-coookbook-access-denied-error/16005 "2019-10-02T18:26:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gangadhar01a](https://avatars.discourse-cdn.com/v4/letter/g/c37758/32.png) [@gangadhar01a](https://discourse.chef.io/u/gangadhar01a)\
**Post date:** [October 2, 2019, 6:26pm UTC](https://discourse.chef.io/t/mysql-chef-coookbook-access-denied-error/16005/1 "2019-10-02T18:26:35Z")

</div>

Hi,

I am using mysql chef supermarket coookbook to set up "default" instance on CentOS 7. I am able to install the mysql and the chef recipe not able to create a root account with the provided password in recipe.

mysql\_service 'default' do  
port '3306'  
version '5.6'  
initial\_root\_password 'rundeck'  
action [:create, :start]  
end

I can access mysql without providing a password  
"mysql -S /var/run/mysql-default/mysqld.sock -u root"

When I tried accesing with password, it resulted in "Access Denied Error"

mysql -S /var/run/mysql-default/mysqld.sock -u root -p  
Enter password:  
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Looks like chef not respecting "initial\_root\_password".

---

<div class="post-metadata">

**Author:** ![gangadhar01a](https://avatars.discourse-cdn.com/v4/letter/g/c37758/32.png) [@gangadhar01a](https://discourse.chef.io/u/gangadhar01a)\
**Post date:** [October 2, 2019, 7:21pm UTC](https://discourse.chef.io/t/mysql-chef-coookbook-access-denied-error/16005/2 "2019-10-02T19:21:30Z")

</div>

I have updated metadata.rb file to use latest mysql chef cookbook (8.5.1). Two things which I have noticed

1. I am unable to access the mysql without password. (this means the chef cookbook tried to set the password)  
2)I am unable to use the password which I have provided in recipe.

[root@rundeck-test cookbooks]# mysql -S /var/run/mysql-default/mysqld.sock -u root

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

[root@rundeck-test cookbooks]# mysql -S /var/run/mysql-default/mysqld.sock -u root -p

Enter password:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

---

<div class="post-metadata">

**Author:** ![trainocate.in](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@trainocate.in](https://discourse.chef.io/u/trainocate.in)\
**Post date:** [October 3, 2019, 7:49am UTC](https://discourse.chef.io/t/mysql-chef-coookbook-access-denied-error/16005/3 "2019-10-03T07:49:47Z")

</div>

You can try this,

`mysql -h '127.0.0.1' -u root -p`

And feed the password 'rundesk' once it prompts
