Chef MySQL cook

Sandeepiii
Sandeepiii used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
David FavorFractional CTO
Distinguished Expert 2018

Commented:
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.

Author

Commented:
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.
David FavorFractional CTO
Distinguished Expert 2018

Commented:
Awesome!

Glad you got this working!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial