pghalliday-cookbooks / sonarqube-mysql

0 stars 2 forks source link

Where should I make changes so that cookbook can access the server and create a user #2

Open sernapallyanurag opened 8 years ago

sernapallyanurag commented 8 years ago

Error executing action create on resource 'mysql_database_user[sonar]'

Mysql2::Error

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.s ock' (2)

Cookbook Trace:

/var/chef/cache/cookbooks/database/libraries/provider_database_mysql_user.rb :221:in new' /var/chef/cache/cookbooks/database/libraries/provider_database_mysql_user.rb :221:intest_client' /var/chef/cache/cookbooks/database/libraries/provider_database_mysql_user.rb :37:in `block in '\

pghalliday commented 8 years ago

Did you set/override the attributes:

default['sonarqube-mysql']['username'] = 'sonar'
default['sonarqube-mysql']['password'] = 'sonar'

default['sonarqube-mysql']['mysql']['host']     = 'localhost'
default['sonarqube-mysql']['mysql']['username'] = 'root'
default['sonarqube-mysql']['mysql']['password'] = 'root'
default['sonarqube-mysql']['mysql']['version']  = '5.7'

default['sonarqube-mysql']['sonarqube']['url'] = 'http://localhost:9000'
sernapallyanurag commented 8 years ago

I have overridden jdbc attributes and I am using version 5.5, I have also added my socket path. I will paste my code here.

default['sonarqube-mysql']['username'] = 'sonar' default['sonarqube-mysql']['password'] = 'sonar'

default['sonarqube-mysql']['mysql']['host'] = 'localhost' default['sonarqube-mysql']['mysql']['username'] = 'root' default['sonarqube-mysql']['mysql']['password'] = 'root' default['sonarqube-mysql']['mysql']['version'] = '5.5' default['sonarqube-mysql']['mysql']['socket'] = '/var/run/mysql-sonar/mysqld.sock'

default['sonarqube-mysql']['sonarqube']['url'] = 'http://localhost:9000'

mysql_service 'sonar' do port '3306' version '5.5' initial_root_password 'root' action [:create, :start] end

This is the error I am getting after adding socket path

root@xyz:~# mysql -S /var/run/mysql-sonar/mysqld.sock -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: Y ES)

sernapallyanurag commented 8 years ago

The Error was in mysql library file helpers.rb we need to replace this part of the code

cat > /tmp/#{mysql_name}/my.sql <<-EOSQL UPDATE mysql.user SET #{password_column_name}=PASSWORD('#{root_password}')# {password_expired} WHERE user = 'root'; DELETE FROM mysql.user WHERE USER LIKE ''; DELETE FROM mysql.user WHERE user = 'root' and host NOT IN ('127.0.0.1', 'localhost'); FLUSH PRIVILEGES; DELETE FROM mysql.db WHERE db LIKE 'test%'; DROP DATABASE IF EXISTS test ; EOSQL

WITH

cat > /tmp/#{mysql_name}/my.sql <<-EOSQL DELETE FROM mysql.user ; CREATE USER 'root'@'%' IDENTIFIED BY '#{Shellwords.escape(new_resource.initial_root_password)}' ; GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION ; FLUSH PRIVILEGES; DROP DATABASE IF EXISTS test ; EOSQL

pghalliday commented 8 years ago

There is no helpers.rb in this project do you mean the mysql gem?

sernapallyanurag commented 8 years ago

Mysql Cookbook libraries.

pghalliday commented 8 years ago

ok can you raise an issue over there then?

sernapallyanurag commented 8 years ago

Thanks a lot for the response.