<commit_before>package 'http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm' do
  not_if 'rpm -q mysql-community-release-el6-5'
end

package 'mysql-community-server'
package 'mysql-community-devel'

execute 'backup /etc/my.cnf' do
  user 'root'
  command <<"EOS"
    cp -p /etc/my.cnf /etc/my.cnf.org
EOS
  not_if 'ls /etc/my.cnf.org'
end

remote_file '/etc/my.cnf' do
  owner 'root'
  group 'root'
end

service "mysqld" do
  action [:enable, :start]
end

MYSQL_PASSWORD = '<PASSWORD>'
execute 'mysql_secure_installation' do
  user 'root'
  command <<"EOS"
    mysql -u root -e "SET PASSWORD=PASSWORD('#{MYSQL_PASSWORD}');"
    mysql -uroot -p#{MYSQL_PASSWORD} -e "DELETE FROM mysql.user WHERE User='';"
    mysql -uroot -p#{MYSQL_PASSWORD} -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');"
    mysql -uroot -p#{MYSQL_PASSWORD} -e "DROP DATABASE test;"
    mysql -uroot -p#{MYSQL_PASSWORD} -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'"
    mysql -uroot -p#{MYSQL_PASSWORD} -e "FLUSH PRIVILEGES;"
    cp -p /etc/my.cnf /etc/my.cnf.org
EOS
  not_if "which mysql"
end<commit_msg>mysqlのバージョンを5.7に変更<commit_after>package 'http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm' do
  not_if 'rpm -q mysql57-community-release-el6-7'
end

package 'mysql-community-server'
package 'mysql-community-devel'

execute 'backup /etc/my.cnf' do
  user 'root'
  command <<"EOS"
    cp -p /etc/my.cnf /etc/my.cnf.org
EOS
  not_if 'ls /etc/my.cnf.org'
end

remote_file '/etc/my.cnf' do
  owner 'root'
  group 'root'
end

service "mysqld" do
  action [:enable, :start]
end

MYSQL_PASSWORD = '<PASSWORD>'
execute 'mysql_secure_installation' do
  user 'root'
  command <<"EOS"
    tmp_pass=$(grep 'temporary password' /var/log/mysqld.log | awk -F"root@localhost: " '{print $2}')
    mysql -u root -p"$tmp_pass" --connect-expired-password -e "SET GLOBAL validate_password_length=4;SET GLOBAL validate_password_policy=LOW;SET PASSWORD FOR root@localhost=PASSWORD('#{MYSQL_PASSWORD}');"
    mysql -uroot -p#{MYSQL_PASSWORD} -e "DELETE FROM mysql.user WHERE User='';"
    mysql -uroot -p#{MYSQL_PASSWORD} -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');"
    mysql -uroot -p#{MYSQL_PASSWORD} -e "DROP DATABASE test;"
    mysql -uroot -p#{MYSQL_PASSWORD} -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'"
    mysql -uroot -p#{MYSQL_PASSWORD} -e "FLUSH PRIVILEGES;"
EOS
  not_if "ls /etc/my.cnf.org"
end
{'fraction_non_alphanumeric': 0.1608419380460683, 'fraction_numerical': 0.011914217633042097, 'mean_word_length': 3.9007782101167314, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 5, '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': '6508539', 'n_tokens_mistral': 1029, 'n_tokens_neox': 1028, 'n_words': 245}