0

I have a vagrant file using puppet to configure mysql.

Here is the relevant code in default.pp:

class { '::mysql::server':
  override_options => { 'mysqld' => { 'bind_address' => '0.0.0.0' } },


  grants => {
    'root@10.0.2.2/*.*' => {
      ensure     => 'present',
      options    => ['GRANT'],
      privileges => ['ALL'],
      table      => '*.*',
      user       => 'root@10.0.2.2',
    },
  },
}

This works, but from the host machine (not the VM) I can only access mysql via 127.0.0.1 and I want to be able to access via localhost (the default for the mysql client).

So my questions are: 1) what is the significance of 10.0.2.2? ( copied and pasted this from an example) 2) how do I configure the mysql install on the VM to be accessible from the host OS (mac) as

mysql -u root -h localhost

I should also note that I tried changing root@10.0.2.2 to root@localhost and this did not work.

thanks! phil

0
  1. 10.0.2.2 is probably the virtual IP address of the guest OS instance using VirtualBox 'HostOnly' networking.

You should be able to connect to the mysql server in the guest instance using

mysql -u root -h 10.0.2.2
  1. "localhost" has a special meaning with MySQL, it causes clients to try to connect via Unix Domain Sockets instead of TCP. So it tries to connect using a socket file, usually either /tmp/mysql.sock or /var/run/mysql/mysql.sock, and these are special files only accessible locally to processes on the same operating system instance.

Your VM is a different OS instance though, and so your mysql client on the host OS can't access domain socket files on the guest OS.

0

10.0.2.2 means for which remote IP you grant access to user, by studying vagrant puphpet template vagrant/puphpet/puphpet/nodes/Mysql.pp you can see template definition manifesto, ruby code:

  each( $grants ) |$key, $grant| {
    # if no host passed with username, default to localhost
    if '@' in $grant['user'] {
      $user = $grant['user']
    } else {
      $user = "${grant['user']}@localhost"
    }

therefore user must by yaml puphpet configured like

grants:
     mysql:
         user: dbuser@%

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.