Question

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.

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)
Was it helpful?

Solution

Don't use root user for creating the database, the mysql::db type is not meant for this. Instead, specify a new user/password, you can always use root for accessing the database later:

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

mysql::db { 'foo':
  user     => 'foo',
  password => 'bar',
  host     => 'localhost',
  sql      => '/vagrant/dump.sql',
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top