gpt4 book ai didi

mysql Chef Cookbook 忽略我的初始 root 密码

转载 作者:行者123 更新时间:2023-11-29 23:13:14 26 4
gpt4 key购买 nike

我正在尝试创建一个说明书包装器来使用 Chef 部署 MySQL,但它似乎没有插入我在说明书中设置的初始 root 密码。

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

我的环境如下:

我使用的 Recipe 是最新版本:

  • mysql 6.0.7
  • 数据库3.0.0

由于未设置初始密码,导致数据库部分失败,无法访问数据库。

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"

任何人都可以提供一些线索,为什么它没有设置初始密码?

提前致谢,-恩里克

最佳答案

...看来您没有看过 mysql Recipe 自述文件:引自:

Usage

Place a dependency on the mysql cookbook in your cookbook's metadata.rb

depends 'mysql', '~> 6.0' Then, in a recipe:

mysql_service 'default' do
port '3306'
version '5.5'
initial_root_password 'change me'
action [:create, :start]
end

mysql_config 'default' do
source 'mysite.cnf.erb'
notifies :restart, 'mysql_service[default]'
action :create
end

mysql_service 资源最终导致 mysql 停止,假设会有一个 mysql_config 资源,之后将重新启动该服务。

关于mysql Chef Cookbook 忽略我的初始 root 密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27980777/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com