Ask Your Question
1

how to mysql_grant with a password, IDENTIFIED BY ‘password’

asked 2015-07-21 11:15:14 -0500

gradetsk gravatar image

HI everyone, so I am working on trying to setup mysql so I can grant permissions so we can test and connect to databases from vagrant box.

I can go into the vagrant box right now and run this command in mysql "GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' IDENTIFIED BY 'password';" and the box will then allow us to connect fine. I try this on puppet.

using https://forge.puppetlabs.com/puppetla... module

with a template like this (can't post password, table or user data on here)

mysql_grant { 'user@%/*.*':
 ensure     => 'present',
 options    => ['GRANT'],
 privileges => ['ALL PRIVILEGES'],
 table      => '*.*',
 user       => 'user@%',
} ->

but the logs output this in debug "GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' WITH GRANT OPTION" and this fails to make the modifications we need to be able to connect to the database successfully. Is there any way to pass in a password so that the module will run IDENIFIED BY 'password' in the grant

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2015-07-22 03:16:03 -0500

I've only used this module simplistically in the past - looking at mine:

mysql::db { 'teradb': user => 'stuadm', password => 'secret', host => 'localhost', grant => ['SELECT', 'UPDATE'], }

this does work and assigns password - which is what you want?

edit flag offensive delete link more

Comments

thanks for the help yes this does lead me to the correct direction I needed to do that as well. In addition to this I needed to add password_hash => mysql_password('password'), to the mysql_user and that fixed the entire problem so thanks a ton.

gradetsk gravatar imagegradetsk ( 2015-07-22 09:06:08 -0500 )edit
1

answered 2015-07-22 09:08:20 -0500

gradetsk gravatar image

so in addition to the mysql:db section you need to add bellow

mysql_user { 'user@%':
  ensure                   => 'present',
  password_hash => mysql_password('password'),
} ->

then

mysql_grant { 'user@%/*.*':
 ensure     => 'present',
 options    => ['GRANT'],
 privileges => ['ALL PRIVILEGES'],
 table      => '*.*',
 user       => 'user@%',
}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-07-21 11:08:20 -0500

Seen: 571 times

Last updated: Jul 22 '15