Closed mruhlin closed 4 years ago
Investigation I've done so far:
mysql_service_base
checks for the existence of #{new_resource.data_dir}/mysql/user.frm
and only generates initial records if that file doesn't exist.
def initialize_database
# initialize database and create initial records
bash "#{new_resource.name} initial records" do
code init_records_script
umask '022'
returns [0, 1, 2] # facepalm
not_if "/usr/bin/test -f #{new_resource.data_dir}/mysql/user.frm"
action :run
end
end
Regardless of what data_dir
is specified, something earlier on in this recipe creates a default database in /var/lib/mysql
, meaning that file always exists.
I haven't yet tracked down where that gets created, but hopefully there is an alternate approach that doesn't need to do that.
Marking stale due to inactivity. Remove stale label or comment or this will be closed in 7 days. Alternatively drop by the #sous-chefs channel on the Chef Community Slack and we'll be happy to help! Thanks, Sous-Chefs.
Closing due to inactivity. If this is still an issue please reopen or open another issue. Alternatively drop by the #sous-chefs channel on the Chef Community Slack and we'll be happy to help! Thanks, Sous-Chefs.
Cookbook version
8.5.2
Chef-client version
13.12.14
Platform Details
Ubuntu 16.04, running in Vagrant and AWS
Scenario:
We're upgrading an existing environment that has been running mysql 5.5 and using the default data location,
/var/lib/mysql
. We have various scripts that expect the data to be in that location, so would like to keep it there.[What you are trying to achieve and you can't?]
When setting the
data_dir
directory, we find that initial records aren't being created. This isn't necessarily a problem in production, since we already have data to put there. But it is a problem when testing the script locally in a dev environment. When the initial records script isn't run,initial_root_password
is not set (even to the supposed default ofilikerandompasswords
). Instead, MySQL 5.7+ reverts to its default behavior of generating a random password, causing subsequent setup scripts to fail.Steps to Reproduce:
/var/lib/mysql
, and specifyinginitial_root_password
mysql_service 'companyname' do port '3306'
bind_address mysql_connection_info[:host]
data_dir '/var/lib/mysql' include_dir '/etc/mysql-companyname/conf.d' pid_file '/var/run/mysqld/mysqld.pid' socket '/var/run/mysqld/mysqld.sock'
initial_root_password mysql_connection_info[:password]
version '5.7' action [:create, :start] end
Load timezone data
bash 'mysql_tzinfo_to_sql' do code "mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql --user=root --password=\"#{mysql_connection_info[:password]}\" mysql" sensitive true end