Mysql cookbook database creation problem: cannot load such file -- mysql2

Hi,

It is my cookbook

mysql_service ‘default’ do
bind_address '0.0.0.0’
initial_root_password 'password’
action [:create, :start]
end

Create a mysql database

mysql_database ‘zeetings’ do
connection(
:host => ‘127.0.0.1’,
:username => ‘data’,
:password => ‘password’
)
action :create
end

It is what I get when I run kitchen converge

================================================================================
Error executing action create on resource
’mysql_database[test]’

================================================================================

       LoadError
       ---------
       cannot load such file -- mysql2

       Cookbook Trace:
       ---------------

/tmp/kitchen/cache/cookbooks/database/libraries/provider_database_mysql.rb:103:in
`test_client’

/tmp/kitchen/cache/cookbooks/database/libraries/provider_database_mysql.rb:37:in
`block in class:Mysql

Did I miss some steps here?

Hi Anthony,

On Mon, Feb 16, 2015 at 07:30:59AM +1100, Anthony Kong wrote:

It is my cookbook

mysql_service 'default' do
bind_address '0.0.0.0'
initial_root_password 'password'
action [:create, :start]
end

Create a mysql database

mysql_database 'zeetings' do
connection(
:host => '127.0.0.1',
:username => 'data',
:password => 'password'
)
action :create
end

It is what I get when I run kitchen converge

LoadError

cannot load such file -- mysql2

Did I miss some steps here?

Since database cookbook version 4, you must install the mysql2 gem by yourself:

mysql2_chef_gem 'default' do
action :install
end

mysql_database 'zeetings' do

[...]

end

And include the mysql2_chef_gem cookbook dependency in your metadata.rb.

From GitHub - chef-boneyard/database: DEPRECATED: Development repository for Chef database cookbook

MySQL: leverages the mysql2 gem, which can be installed with the
mysql2_chef_gem resource prior to use (available on the Supermarket). You
must depend on the mysql2_chef_gem cookbook, then use a mysql2_chef_gem
resource to install it. The resource allows the user to select MySQL client
library versions, as well as optionally select MariaDB libraries.

Regards,

--
Xabier de Zuazo