简体   繁体   English

使用puppetlabs-mysql将dump.sql导入mysql数据库

[英]Import a dump.sql into mysql database with puppetlabs-mysql

Using puppet as a Vagrant provider and the puppetlabs-mysql module (2.2.3) I'm not able to import a sql dump on a db with root user and no password. 使用puppet作为Vagrant提供程序和puppetlabs-mysql模块 (2.2.3),我无法使用root用户且没有密码在db上导入sql dump。

This is the puppet code I'm using: 这是我正在使用的木偶代码:

class { '::mysql::server': }

mysql::db { 'foo':
  user     => 'root',
  password => '',
  host     => 'localhost',
  sql      => '/vagrant/dump.sql',
}

This is the box: 这是盒子:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.3 LTS
Release:        12.04
Codename:       precise

$ puppet --version
3.3.2

This is the error: 这是错误:

Error: Could not prefetch mysql_grant 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)

Don't use root user for creating the database, the mysql::db type is not meant for this. 不要使用root用户来创建数据库, mysql::db类型并不适用于此。 Instead, specify a new user/password, you can always use root for accessing the database later: 而是指定一个新的用户/密码,您以后始终可以使用root来访问数据库:

class { '::mysql::server': }

mysql::db { 'foo':
  user     => 'foo',
  password => 'bar',
  host     => 'localhost',
  sql      => '/vagrant/dump.sql',
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM