Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
7
Help us understand the problem. What is going on with this article?
@moscowmule2240

Vagrant仮想マシン上にMySQL5.5インストール

More than 5 years have passed since last update.

MySQLインストール

Berkshelf

Berkshelfファイルにcookbookを指定します。

source "https://api.berkshelf.com"

cookbook 'mysql'

cookbookダウンロード

cookbooksディレクトリが存在するとダウンロード出来ないので、削除してダウンロードします。

rm -fr cookbooks
/opt/chef/embedded/bin/berks vendor cookbooks

Vagrantfile

Vagrantfileへrecipeとattributesを追加します。

  config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = ["cookbooks", "site-cookbooks"]
    chef.add_recipe "mysql"

    chef.json = {
      mysql: {
        version: "5.5",
        server_root_password: "",
      },
    }
  end

MySQL conf

character-setをutf8にする設定を追加します。

cookbookの作成

mysql-confという名前でcookbookを作ります。

knife cookbook create mysql-conf -o site-cookbooks/

recipeの作成

site-cookbooks/mysql-conf/recipes/default.rbを編集します。
ここに実行する内容を記述します。

  • cookbook内のファイルのコピー
  • mysqldサービスの再起動
default.rb
cookbook_file "/etc/mysql/conf.d/character-set.cnf" do
  source "character-set.cnf"
  owner "mysql"
  group "mysql"
  mode "755"
end

cookbook_file "/etc/mysql/conf.d/engine.cnf" do
  source "engine.cnf"
  owner "mysql"
  group "mysql"
  mode "755"
end

service 'mysqld' do
  action [:restart, ]
end

コピーファイルの作成

site-cookbooks/mysql-conf/files/default配下にファイルを置きます。

character-set.cnf
[mysqld]
skip-character-set-client-handshake
character-set-server = utf8
collation-server = utf8_general_ci
init-connect = SET NAMES utf8

[client]
default-character-set = utf8

[mysqldump]
default-character-set = utf8

[mysql]
default-character-set = utf8
engine.cnf
[mysqld]
default-storage-engine = InnoDB

recipeに追加

Vagrantfileにrecipeを追加します。

  config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = ["cookbooks", "site-cookbooks"]
    chef.add_recipe "mysql::server"
    chef.add_recipe "mysql-conf"
  end

起動

vagrant up

リンク

Vagrant初期設定
自分で作成したcookbookをVagrantで適用する
VagrantでCentOS外部レポジトリの追加
Vagrant仮想マシン上にMySQL5.5インストール
Vagrant仮想マシン上のMySQLに接続
Vagrant仮想マシン上にredis2.8.12インストール

7
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
7
Help us understand the problem. What is going on with this article?