{"id":19249304,"url":"https://github.com/sous-chefs/mysql","last_synced_at":"2025-05-16T02:09:57.826Z","repository":{"id":2725934,"uuid":"3720862","full_name":"sous-chefs/mysql","owner":"sous-chefs","description":"Development repository for the mysql cookbook","archived":false,"fork":false,"pushed_at":"2024-12-09T16:14:42.000Z","size":1854,"stargazers_count":341,"open_issues_count":23,"forks_count":691,"subscribers_count":78,"default_branch":"main","last_synced_at":"2025-05-07T09:34:55.345Z","etag":null,"topics":["chef","chef-cookbook","chef-resource","hacktoberfest","managed-by-terraform","mysql"],"latest_commit_sha":null,"homepage":"https://supermarket.chef.io/cookbooks/mysql","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sous-chefs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"open_collective":"sous-chefs"}},"created_at":"2012-03-14T18:34:56.000Z","updated_at":"2025-05-03T06:47:53.000Z","dependencies_parsed_at":"2025-04-19T18:27:27.883Z","dependency_job_id":"a7f171ae-c1db-4ebb-97ea-971675563359","html_url":"https://github.com/sous-chefs/mysql","commit_stats":{"total_commits":1158,"total_committers":173,"mean_commits":6.69364161849711,"dds":0.8583765112262521,"last_synced_commit":"5b4e3a98fe9a7bbbdcb5ab9b838c262e180bdcb1"},"previous_names":[],"tags_count":157,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sous-chefs%2Fmysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sous-chefs%2Fmysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sous-chefs%2Fmysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sous-chefs%2Fmysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sous-chefs","download_url":"https://codeload.github.com/sous-chefs/mysql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254453667,"owners_count":22073618,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chef","chef-cookbook","chef-resource","hacktoberfest","managed-by-terraform","mysql"],"created_at":"2024-11-09T18:13:40.789Z","updated_at":"2025-05-16T02:09:57.808Z","avatar_url":"https://github.com/sous-chefs.png","language":"Ruby","funding_links":["https://opencollective.com/sous-chefs"],"categories":[],"sub_categories":[],"readme":"\n# MySQL Cookbook\n\n[![Cookbook Version](https://img.shields.io/cookbook/v/mysql.svg)](https://supermarket.chef.io/cookbooks/mysql)\n[![Build Status](https://img.shields.io/circleci/project/github/sous-chefs/mysql/master.svg)](https://circleci.com/gh/sous-chefs/mysql)\n[![OpenCollective](https://opencollective.com/sous-chefs/backers/badge.svg)](#backers)\n[![OpenCollective](https://opencollective.com/sous-chefs/sponsors/badge.svg)](#sponsors)\n[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)\n\nThe 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.\n\n## Scope\n\nThis 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 MariaDB or Percona.\n\n## Maintainers\n\nThis cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit [sous-chefs.org](https://sous-chefs.org/) or come chat with us on the Chef Community Slack in [#sous-chefs](https://chefcommunity.slack.com/messages/C2V7B88SF).\n\n## Requirements\n\n- Chef 15.5 or higher\n- Network accessible package repositories\n- 'recipe[selinux::disabled]' on RHEL platforms\n\n## Platform Support\n\nThe following platforms have been tested with Test Kitchen:\n\n|  OS            | 5.6 | 5.7 | 8.0 |\n|----------------|-----|-----|-----|\n| centos-7       |  X  |  X  |  X  |\n| centos-8       |     |  X  |  X  |\n| debian-9       |     |  X  |     |\n| debian-10      |     |     |  X  |\n| fedora         |  X  |  X  |  X  |\n| openSUSE Leap  |  X  |     |     |\n| ubuntu-18.04   |     |  X  |     |\n| ubuntu-20.04   |     |     |  X  |\n| ubuntu-22.04   |     |     |  X  |\n\n## Cookbook Dependencies\n\nThere are no hard coupled dependencies. However, there is a loose dependency on `yum-mysql-community` for RHEL/CentOS platforms. As of the 8.0 version of this cookbook, configuration of the package repos is now the responsibility of the user.\n\n## Usage\n\nPlace a dependency on the mysql cookbook in your cookbook's metadata.rb\n\n```ruby\ndepends 'mysql'\n```\n\nThen, in a recipe:\n\n```ruby\nmysql_service 'foo' do\n  port '3306'\n  version '8.0'\n  initial_root_password 'change me'\n  action [:create, :start]\nend\n```\n\nThe 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`.\n\nIf you use `default` as the name the service name will be `mysql` instead of `mysql-default`.\n\nThe configuration file is at `/etc/mysql-foo/my.cnf`. It contains the minimum options to get the service running. It looks like this.\n\n```cnf\n# Chef generated my.cnf for instance mysql-foo\n\n[client]\ndefault-character-set          = utf8\nport                           = 3306\nsocket                         = /var/run/mysql-foo/mysqld.sock\n\n[mysql]\ndefault-character-set          = utf8\n\n[mysqld]\nuser                           = mysql\npid-file                       = /var/run/mysql-foo/mysqld.pid\nsocket                         = /var/run/mysql-foo/mysqld.sock\nport                           = 3306\ndatadir                        = /var/lib/mysql-foo\ntmpdir                         = /tmp\nlog-error                      = /var/log/mysql-foo/error.log\n!includedir /etc/mysql-foo/conf.d\n\n[mysqld_safe]\nsocket                         = /var/run/mysql-foo/mysqld.sock\n```\n\nYou can put extra configuration into the conf.d directory by using the `mysql_config` resource, like this:\n\n```ruby\nmysql_service 'foo' do\n  port '3306'\n  version '8.0'\n  initial_root_password 'change me'\n  action [:create, :start]\nend\n\nmysql_config 'foo' do\n  source 'my_extra_settings.erb'\n  instance 'foo'\n  notifies :restart, 'mysql_service[foo]'\n  action :create\nend\n```\n\nYou are responsible for providing `my_extra_settings.erb` in your own cookbook's templates folder. The name of the mysql service instance must be provided in mysql config as this defaults to 'default'.\n\n## Connecting with the mysql CLI command\n\nLogging 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`\n\n## Upgrading from older version of the mysql cookbook\n\n- It is strongly recommended that you rebuild the machine from scratch. This is easy if you have your `data_dir` on a dedicated mount point. If you _must_ upgrade in-place, follow the instructions below.\n- The 6.x series supports multiple service instances on a single machine. It dynamically names the support directories and service names. `/etc/mysql becomes /etc/mysql-instance_name`. Other support directories in `/var` `/run` etc work the same way. Make sure to specify the `data_dir` property on the `mysql_service` resource to point to the old `/var/lib/mysql` directory.\n\n## Resources\n\n- [`mysql_service`](https://github.com/sous-chefs/mysql/blob/master/documentation/resource_mysql_service.md)\n- [`mysql_config`](https://github.com/sous-chefs/mysql/blob/master/documentation/resource_mysql_config.md)\n- [`mysql_client`](https://github.com/sous-chefs/mysql/blob/master/documentation/resource_mysql_client.md)\n- [`mysql_user`](https://github.com/sous-chefs/mysql/blob/master/documentation/resource_mysql_user.md)\n- [`mysql_database`](https://github.com/sous-chefs/mysql/blob/master/documentation/resource_mysql_database.md)\n\n## Advanced Usage Examples\n\nThere are a number of configuration scenarios supported by the use of resource primitives in recipes. For example, you might want to run multiple MySQL services, as different users, and mount block devices that contain pre-existing databases.\n\n### Multiple Instances as Different Users\n\n```ruby\n# instance-1\nuser 'alice' do\n  action :create\nend\n\ndirectory '/mnt/data/mysql/instance-1' do\n  owner 'alice'\n  action :create\nend\n\nmount '/mnt/data/mysql/instance-1' do\n  device '/dev/sdb1'\n  fstype 'ext4'\n  action [:mount, :enable]\nend\n\nmysql_service 'instance-1' do\n  port '3307'\n  run_user 'alice'\n  data_dir '/mnt/data/mysql/instance-1'\n  action [:create, :start]\nend\n\nmysql_config 'site config for instance-1' do\n  instance 'instance-1'\n  source 'instance-1.cnf.erb'\n  notifies :restart, 'mysql_service[instance-1]'\nend\n\n# instance-2\nuser 'bob' do\n  action :create\nend\n\ndirectory '/mnt/data/mysql/instance-2' do\n  owner 'bob'\n  action :create\nend\n\nmount '/mnt/data/mysql/instance-2' do\n  device '/dev/sdc1'\n  fstype 'ext3'\n  action [:mount, :enable]\nend\n\nmysql_service 'instance-2' do\n  port '3308'\n  run_user 'bob'\n  data_dir '/mnt/data/mysql/instance-2'\n  action [:create, :start]\nend\n\nmysql_config 'site config for instance-2' do\n  instance 'instance-2'\n  source 'instance-2.cnf.erb'\n  notifies :restart, 'mysql_service[instance-2]'\nend\n```\n\n### Replication Testing\n\nUse multiple `mysql_service` instances to test a replication setup. This particular example serves as a smoke test in Test Kitchen because it exercises different resources and requires service restarts.\n\n\u003chttps://github.com/sous-chefs/mysql/blob/main/test/cookbooks/test/recipes/service_multi.rb\u003e\n\n## Frequently Asked Questions\n\n### How do I run this behind my firewall\n\nOn Linux, the `mysql_service` resource uses the platform's underlying package manager to install software. For this to work behind firewalls, you'll need to either:\n\n- Configure the system yum/apt utilities to use a proxy server that\n- can reach the Internet\n- Host a package repository on a network that the machine can talk to\n\nOn the RHEL platform_family, applying the `yum::default` recipe will allow you to drive the `yum_globalconfig` resource with attributes to change the global yum proxy settings.\n\nIf hosting repository mirrors, applying one of the following recipes and adjust the settings with node attributes.\n\n- `recipe[yum-centos::default]` from the Supermarket\n\n  \u003chttps://supermarket.chef.io/cookbooks/yum-centos\u003e\n\n  \u003chttps://github.com/chef-cookbooks/yum-centos\u003e\n\n- `recipe[yum-mysql-community::default]` from the Supermarket\n\n  \u003chttps://supermarket.chef.io/cookbooks/yum-mysql-community\u003e\n\n  \u003chttps://github.com/chef-cookbooks/yum-mysql-community\u003e\n\n### The mysql command line doesn't work\n\nIf you log into the machine and type `mysql`, you may see an error like this one:\n\n`Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'`\n\nThis is because MySQL is hardcoded to read the defined default my.cnf file, typically at /etc/my.cnf, and this LWRP deletes it to prevent overlap among multiple MySQL configurations.\n\nTo connect to the socket from the command line, check the socket in the relevant my.cnf file and use something like this:\n\n`mysql -S /var/run/mysql-foo/mysqld.sock -Pwhatever`\n\nOr to connect over the network, use something like this: connect over the network..\n\n`mysql -h 127.0.0.1 -Pwhatever`\n\nThese network or socket ssettings can also be put in you $HOME/.my.cnf, if preferred.\n\n### What about MariaDB, Percona, etc\n\nMySQL forks are purposefully out of scope for this cookbook. This is mostly to reduce the testing matrix to a manageable size. Cookbooks for these technologies can easily be created by copying and adapting this cookbook. However, there will be differences.\n\nPackage repository locations, package version names, software major version numbers, supported platform matrices, and the availability of software such as XtraDB and Galera are the main reasons that creating multiple cookbooks to make sense.\n\nThere are existing cookbooks to carter for these forks, check them out on the supermarket\n\n## Contributors\n\nThis project exists thanks to all the people who [contribute.](https://opencollective.com/sous-chefs/contributors.svg?width=890\u0026button=false)\n\n### Backers\n\nThank you to all our backers!\n\n![https://opencollective.com/sous-chefs#backers](https://opencollective.com/sous-chefs/backers.svg?width=600\u0026avatarHeight=40)\n\n### Sponsors\n\nSupport this project by becoming a sponsor. Your logo will show up here with a link to your website.\n\n![https://opencollective.com/sous-chefs/sponsor/0/website](https://opencollective.com/sous-chefs/sponsor/0/avatar.svg?avatarHeight=100)\n![https://opencollective.com/sous-chefs/sponsor/1/website](https://opencollective.com/sous-chefs/sponsor/1/avatar.svg?avatarHeight=100)\n![https://opencollective.com/sous-chefs/sponsor/2/website](https://opencollective.com/sous-chefs/sponsor/2/avatar.svg?avatarHeight=100)\n![https://opencollective.com/sous-chefs/sponsor/3/website](https://opencollective.com/sous-chefs/sponsor/3/avatar.svg?avatarHeight=100)\n![https://opencollective.com/sous-chefs/sponsor/4/website](https://opencollective.com/sous-chefs/sponsor/4/avatar.svg?avatarHeight=100)\n![https://opencollective.com/sous-chefs/sponsor/5/website](https://opencollective.com/sous-chefs/sponsor/5/avatar.svg?avatarHeight=100)\n![https://opencollective.com/sous-chefs/sponsor/6/website](https://opencollective.com/sous-chefs/sponsor/6/avatar.svg?avatarHeight=100)\n![https://opencollective.com/sous-chefs/sponsor/7/website](https://opencollective.com/sous-chefs/sponsor/7/avatar.svg?avatarHeight=100)\n![https://opencollective.com/sous-chefs/sponsor/8/website](https://opencollective.com/sous-chefs/sponsor/8/avatar.svg?avatarHeight=100)\n![https://opencollective.com/sous-chefs/sponsor/9/website](https://opencollective.com/sous-chefs/sponsor/9/avatar.svg?avatarHeight=100)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsous-chefs%2Fmysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsous-chefs%2Fmysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsous-chefs%2Fmysql/lists"}