<commit_before>#
# Cookbook Name:: mysql_part
# Recipe:: create_database
#
# Copyright 2014, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#

include_recipe 'database::mysql'

mysql_connection_info = {
  host:     '127.0.0.1',
  username: 'root',
  password: node['mysql']['server_root_password']
}

mysql_database node['mysql_part']['app']['database'] do
  connection mysql_connection_info
  encoding node['mysql_part']['app']['encoding']
  action :create
end

# create database user
mysql_database_user 'create database user' do
  username node['mysql_part']['app']['username']
  connection mysql_connection_info
  password node['mysql_part']['app']['password']
  action :create
end

# Grant database
mysql_database_user 'Grant database' do
  username node['mysql_part']['app']['username']
  connection mysql_connection_info
  database_name node['mysql_part']['app']['database']
  host '%'
  privileges node['mysql_part']['app']['privileges']
  require_ssl node['mysql_part']['app']['require_ssl']
  action :grant
end

mysql_database 'flush the privileges' do
  connection mysql_connection_info
  sql 'flush privileges'<commit_msg>Fix host parameter in case of creating user.<commit_after>#
# Cookbook Name:: mysql_part
# Recipe:: create_database
#
# Copyright 2014, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#

include_recipe 'database::mysql'

mysql_connection_info = {
  host:     '127.0.0.1',
  username: 'root',
  password: node['mysql']['server_root_password']
}

mysql_database node['mysql_part']['app']['database'] do
  connection mysql_connection_info
  encoding node['mysql_part']['app']['encoding']
  action :create
end

# create database user
mysql_database_user 'create database user' do
  username node['mysql_part']['app']['username']
  connection mysql_connection_info
  host '%'
  password node['mysql_part']['app']['password']
  action :create
end

# Grant database
mysql_database_user 'Grant database' do
  username node['mysql_part']['app']['username']
  connection mysql_connection_info
  database_name node['mysql_part']['app']['database']
  host '%'
  privileges node['mysql_part']['app']['privileges']
  require_ssl node['mysql_part']['app']['require_ssl']
  action :grant
end

mysql_database 'flush the privileges' do
  connection mysql_connection_info
  sql 'flush privileges'
{'fraction_non_alphanumeric': 0.1348122866894198, 'fraction_numerical': 0.008532423208191127, 'mean_word_length': 6.688524590163935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7553335', 'n_tokens_mistral': 705, 'n_tokens_neox': 686, 'n_words': 169}