在 Puppet 上设置 mysql root 密码

Set mysql root password on Puppet

我已经下载了 puppetlabs-mysql module 的最新版本 (3.30),但我无法定义 root 密码。我的 OS 是 Ubuntu 14.04.2 LTS

当我尝试 运行:

class {'::mysql::server':
remove_default_accounts => true,
create_root_user => true,
create_root_my_cnf => true,
root_password => $mysql_server_root_password,
}

我收到以下消息:

Notice: Compiled catalog for joseguilherme-virtualbox in environment production in 0.53 seconds
Notice: /Stage[main]/Mysql::Server::Install/Package[mysql-server]/ensure: ensure changed 'purged' to 'present'
Notice: /Stage[main]/Mysql::Server::Config/File[mysql-config-file]/content: content changed '{md5}77f15d6c87f9c136c4efcda072017f71' to '{md5}790c6c49aed83ee9b81fa3c7360898c8'
Notice: /Stage[main]/Mysql::Server::Service/File[/var/log/mysql/error.log]/group: group changed 'adm' to 'mysql'
Error: Could not prefetch mysql_user provider 'mysql': Execution of '/usr/bin/mysql -NBe SELECT CONCAT(User, '@',Host) AS User FROM mysql.user' returned 1: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Error: Execution of '/usr/bin/mysql -e CREATE USER 'root'@'localhost' IDENTIFIED BY PASSWORD '*0646FA81148FBF3DB9D94E1F0FF3DDF1407A6A68'' returned 1: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Error: /Stage[main]/Mysql::Server::Root_password/Mysql_user[root@localhost]/ensure: change from absent to present failed: Execution of '/usr/bin/mysql -e CREATE USER 'root'@'localhost' IDENTIFIED BY PASSWORD '*0646FA81148FBF3DB9D94E1F0FF3DDF1407A6A68'' returned 1: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Puppet 可以正常安装 mysql-server 但在尝试定义 root 密码时失败。此外,不会创建 /root/.my.cnf 文件。我该如何解决这个问题?

感谢您的帮助!

您的 root 用户已被删除或他的权限被撤销。不幸的是 puppet 将能够恢复它。你将不得不手动完成。因此,您必须以另一个用户 create root and/or add proper privileges. If it will not work, please to follow the guides how to restore deleted root user 1, 2, 3 的身份登录 mysql。通常你必须 运行 mysqldskip-grant-tables 选项。