<commit_before>MySQL Cookbook
=====================

The Mysql Cookbook is a library cookbook that provides resource primitives
(LWRPs) for use in recipes. It is designed to be a reference example for
creating highly reusable cross-platform cookbooks.

Scope
-----
This cookbook is concerned with the "MySQL Community Server",
particularly those shipped with F/OSS Unix and Linux distributions. It
does not address forks or value-added repackaged MySQL distributions
like Drizzle, MariaDB, or Percona.

Requirements
------------
- Chef 11 or higher
- Ruby 1.9 or higher (preferably from the Chef full-stack installer)
- Network accessible package repositories
- 'recipe[selinux::disabled]' on RHEL platforms

Platform Support
----------------
The following platforms have been tested with Test Kitchen:

```
|----------------+-----+-----+-----+-----+-----|
|                | 5.0 | 5.1 | 5.5 | 5.6 | 5.7 |
|----------------+-----+-----+-----+-----+-----|
| debian-7       |     |     | X   |     |     |
|----------------+-----+-----+-----+-----+-----|
| ubuntu-10.04   |     | X   |     |     |     |
|----------------+-----+-----+-----+-----+-----|
| ubuntu-12.04   |     |     | X   |     |     |
|----------------+-----+-----+-----+-----+-----|
| ubuntu-14.04   |     |     | X   | X   |     |
|----------------+-----+-----+-----+-----+-----|
| centos-5       |   X | X   | X   | X   | X   |
|----------------+-----+-----+-----+-----+-----|
| centos-6       |     | X   | X   | X   | X   |
|----------------+-----+-----+-----+-----+-----|
| centos-7       |     |     | X   | X   | X   |
|----------------+-----+-----+-----+-----+-----|
| amazon         |     |     | X   | X   | X   |
|----------------+-----+-----+-----+-----+-----|
| fedora-20      |     |     | X   | X   | X   |
|----------------+-----+-----+-----+-----+-----|
| suse-11.3      |     |     | X   |     |     |
|----------------+-----+-----+-----+-----+-----|
| omnios-151006  |     |     | X   | X   |     |
|----------------+-----+-----+-----+-----+-----|
| smartos-14.3.0 |     |     | X   | X   |     |
|----------------+-----+-----+-----+-----+-----|
```

Cookbook Dependencies
------------
- yum-mysql-community
- smf

Usage
-----
Place a dependency on the mysql cookbook in your cookbook's metadata.rb
```ruby
depends 'mysql', '~> 6.0'
```

Then, in a recipe:

```ruby
mysql_service 'foo' do
  port '3306'
  version '5.5'
  initial_root_password '<PASSWORD>'
  action [:create, :start]
end
```

The service name on the OS is `mysql-foo`. You can manually start and
stop it with `service mysql-foo start` and `service mysql-foo stop`.

The configuration file is at `/etc/mysql-foo/my.cnf`. It contains the
minimum options to get the service running. It looks like this.

```
# Chef generated my.cnf for instance mysql-default

[client]
default-character-set          = utf8
port                           = 3306
socket                         = /var/run/mysql-foo/mysqld.sock

[mysql]
default-character-set          = utf8

[mysqld]
user                           = mysql
pid-file                       = /var/run/mysql-foo/mysqld.pid
socket                         = /var/run/mysql-foo/mysqld.sock
port                           = 3306
datadir                        = /var/lib/mysql-foo
tmpdir                         = /tmp
log-error                      = /var/log/mysql-foo/error.log
!includedir /etc/mysql-foo/conf.d

[mysqld_safe]
socket                         = /var/run/mysql-foo/mysqld.sock
```

You can put extra configuration into the conf.d directory by using the
`mysql_config` resource, like this:

```
mysql_service 'foo' do
  port '3306'
  version '5.5'
  initial_root_password '<PASSWORD>'
  action [:create, :start]
end

mysql_config 'foo' do
  source 'my_extra_settings.erb'
  notifies :restart, 'mysql_service[foo]'
  action :create
end
```

You are responsible for providing `my_extra_settings.erb` in your own
cookbook's templates folder.

Connecting with the mysql CLI command
-------------------------------------
Logging into the machine and typing `mysql` with no extra arguments
will fail. You need to explicitly connect over the socket with `mysql
-S /var/run/mysql-foo/mysqld.sock`, or over the network with `mysql -h
127.0.0.1`
<commit_msg>adding ruby syntax highlighting to README markdown<commit_after>MySQL Cookbook
=====================

The Mysql Cookbook is a library cookbook that provides resource primitives
(LWRPs) for use in recipes. It is designed to be a reference example for
creating highly reusable cross-platform cookbooks.

Scope
-----
This cookbook is concerned with the "MySQL Community Server",
particularly those shipped with F/OSS Unix and Linux distributions. It
does not address forks or value-added repackaged MySQL distributions
like Drizzle, MariaDB, or Percona.

Requirements
------------
- Chef 11 or higher
- Ruby 1.9 or higher (preferably from the Chef full-stack installer)
- Network accessible package repositories
- 'recipe[selinux::disabled]' on RHEL platforms

Platform Support
----------------
The following platforms have been tested with Test Kitchen:

```
|----------------+-----+-----+-----+-----+-----|
|                | 5.0 | 5.1 | 5.5 | 5.6 | 5.7 |
|----------------+-----+-----+-----+-----+-----|
| debian-7       |     |     | X   |     |     |
|----------------+-----+-----+-----+-----+-----|
| ubuntu-10.04   |     | X   |     |     |     |
|----------------+-----+-----+-----+-----+-----|
| ubuntu-12.04   |     |     | X   |     |     |
|----------------+-----+-----+-----+-----+-----|
| ubuntu-14.04   |     |     | X   | X   |     |
|----------------+-----+-----+-----+-----+-----|
| centos-5       |   X | X   | X   | X   | X   |
|----------------+-----+-----+-----+-----+-----|
| centos-6       |     | X   | X   | X   | X   |
|----------------+-----+-----+-----+-----+-----|
| centos-7       |     |     | X   | X   | X   |
|----------------+-----+-----+-----+-----+-----|
| amazon         |     |     | X   | X   | X   |
|----------------+-----+-----+-----+-----+-----|
| fedora-20      |     |     | X   | X   | X   |
|----------------+-----+-----+-----+-----+-----|
| suse-11.3      |     |     | X   |     |     |
|----------------+-----+-----+-----+-----+-----|
| omnios-151006  |     |     | X   | X   |     |
|----------------+-----+-----+-----+-----+-----|
| smartos-14.3.0 |     |     | X   | X   |     |
|----------------+-----+-----+-----+-----+-----|
```

Cookbook Dependencies
------------
- yum-mysql-community
- smf

Usage
-----
Place a dependency on the mysql cookbook in your cookbook's metadata.rb
```ruby
depends 'mysql', '~> 6.0'
```

Then, in a recipe:

```ruby
mysql_service 'foo' do
  port '3306'
  version '5.5'
  initial_root_password '<PASSWORD>'
  action [:create, :start]
end
```

The service name on the OS is `mysql-foo`. You can manually start and
stop it with `service mysql-foo start` and `service mysql-foo stop`.

The configuration file is at `/etc/mysql-foo/my.cnf`. It contains the
minimum options to get the service running. It looks like this.

```
# Chef generated my.cnf for instance mysql-default

[client]
default-character-set          = utf8
port                           = 3306
socket                         = /var/run/mysql-foo/mysqld.sock

[mysql]
default-character-set          = utf8

[mysqld]
user                           = mysql
pid-file                       = /var/run/mysql-foo/mysqld.pid
socket                         = /var/run/mysql-foo/mysqld.sock
port                           = 3306
datadir                        = /var/lib/mysql-foo
tmpdir                         = /tmp
log-error                      = /var/log/mysql-foo/error.log
!includedir /etc/mysql-foo/conf.d

[mysqld_safe]
socket                         = /var/run/mysql-foo/mysqld.sock
```

You can put extra configuration into the conf.d directory by using the
`mysql_config` resource, like this:

```ruby
mysql_service 'foo' do
  port '3306'
  version '5.5'
  initial_root_password '<PASSWORD>'
  action [:create, :start]
end

mysql_config 'foo' do
  source 'my_extra_settings.erb'
  notifies :restart, 'mysql_service[foo]'
  action :create
end
```

You are responsible for providing `my_extra_settings.erb` in your own
cookbook's templates folder.

Connecting with the mysql CLI command
-------------------------------------
Logging into the machine and typing `mysql` with no extra arguments
will fail. You need to explicitly connect over the socket with `mysql
-S /var/run/mysql-foo/mysqld.sock`, or over the network with `mysql -h
127.0.0.1`

{'fraction_non_alphanumeric': 0.2655902655902656, 'fraction_numerical': 0.01755001755001755, 'mean_word_length': 1.3399945250479057, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5573628', 'n_tokens_mistral': 2801, 'n_tokens_neox': 2585, 'n_words': 713}