我正在尝试创建一个食谱包装器来部署带有厨师的MySQL,但它似乎没有插入我正在设置的菜谱中的初始根密码。
mysql_client 'default' do
version '5.6'
action :create
end
if node['kaltiot_mysql']['deployServer'] == 'true'
#-------------------------------------------
# Create the database server and start it
#-------------------------------------------
mysql_service 'default' do
port '3306'
version '5.6'
initial_root_password node['mysql']['initial_root_password']
action [:create, :start]
end
#-------------------------------------------
# Create the database and the user to access
#-------------------------------------------
include_recipe 'database::mysql'
connection_params = {
:host => 'localhost',
:username => 'root',
:password => node['mysql']['initial_root_password']
}
mysql_database 'test' do
connection connection_params
action :create
end
mysql_database_user 'usertest' do
connection connection_params
password node['mysql']['initial_root_password']
privileges [:all]
action [:create, :grant]
end
end我的环境如下:
我正在使用的食谱是最新的版本:
由于未设置初始密码,数据库部件由于无法访问数据库而失败。
shell上的日志如下:
* bash[default :create initialize mysql database] action run[2015-01-16T10:03:03+00:00] INFO: Processing bash[default :create initialize mysql database] action run (/tmp/kitchen/cache/cookbooks/mysql/libraries/provider_mysql_service.rb line 143)
Installing MySQL system tables... 2015-01-16 10:03:03 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
OK
Filling help tables...
2015-01-16 10:03:06 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h default-centos-66.vagrantup.com password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
[2015-01-16T10:03:08+00:00] INFO: bash[default :create initialize mysql database] ran successfully
- execute "bash" "/tmp/chef-script20150116-2184-1tou5sq"
* bash[default :create initial records] action nothing[2015-01-16T10:03:08+00:00] INFO: Processing bash[default :create initial records] action nothing (/tmp/kitchen/cache/cookbooks/mysql/libraries/provider_mysql_service.rb line 152)
(skipped due to action :nothing)
[2015-01-16T10:03:08+00:00] INFO: bash[default :create initialize mysql database] sending run action to bash[default :create initial records] (delayed)
* bash[default :create initial records] action run[2015-01-16T10:03:08+00:00] INFO: Processing bash[default :create initial records] action run (/tmp/kitchen/cache/cookbooks/mysql/libraries/provider_mysql_service.rb line 152)
150116 10:03:08 mysqld_safe Logging to '/var/log/mysql-default/error.log'.
150116 10:03:08 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql-default
150116 10:03:12 mysqld_safe mysqld from pid file /var/run/mysql-default/mysqld.pid ended
[2015-01-16T10:03:12+00:00] INFO: bash[default :create initial records] ran successfully
- execute "bash" "/tmp/chef-script20150116-2184-gjywc9" 任何人都可以带来一些启示,为什么它没有设置这个初始密码?
谢谢你,-Enrique
发布于 2015-01-16 13:12:04
..。似乎您没有看过mysql食谱Readme:引用它:
使用 在食谱的metadata.rb中对mysql食谱设置一个依赖项
depends 'mysql', '~> 6.0' Then, in a recipe:mysql_service 'default‘do port '3306’版本'5.5‘initial_root_password 'change me’action :create,:start end mysql_config 'default‘do source 'mysite.cnf.erb’通知:重新启动,'mysql_servicedefault‘操作:创建结束
mysql_service资源在mysql停止后,假设会有一个mysql_config资源,在此之后将重新启动服务。
https://stackoverflow.com/questions/27980777
复制相似问题