Link to home
Start Free TrialLog in
Avatar of Sandeep rathore
Sandeep rathoreFlag for India

asked on

Chef MySQL cook

Hi Experts
I have installed Mysql 5.7 package via chef.
Now when in try to create Database iam getting error,
Iam using the below to Create Database on Mysql:

mysql_database 'test' do
 connection mysql_server_connection
 action :create
end
mysql_database gives me error like method is undefined.
First i need to install the mysql2 gem

if i try to install mysql2_chef_gem i get error Package: No candidate version available for mysql-community-client, mysql-community-devel

I was unable to install mysql2_chef_gem which i have seen on the marketplace cookbooks but it does not work for me .
Any help or pointers will be very helpful for me.thanks
Avatar of David Favor
David Favor
Flag of United States of America image

First do your database create using the mysql command line tool.

If this works, then just drop the database. At this point you'll know if your database subsystem is installed + working correctly.

This looks odd...

mysql_database 'test' do
 connection mysql_server_connection
 action :create
end

Open in new window


There's no admin user/pass credential which has privilege to create a database.

I don't use Chef so maybe this credential lives somewhere in a Chef config file.

Just make sure an admin credential lives somewhere, else all database creates will fail.

Note: When I visit https://supermarket.chef.io/cookbooks/mysql_chef_gem the following message emits...

The mysql_chef_gem cookbook has been deprecated and is no longer being maintained by its authors. Use of the mysql_chef_gem cookbook is no longer recommended.

This does not inspire confidence using Chef + MySQL.

I suggest you just install the Ruby gem + verify you can get this working in Ruby, before working with Chef.
Avatar of Sandeep rathore

ASKER

Thanks for your advise on this question:
I will try to install Ruby gem and test.
I tried to run the
 command mysql -h -u -p -e \'CREATE DATABASE test\'" this command line command works from the chef.
Awesome!

Glad you got this working!
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.