21

I am trying to get MySQL server (which is inside VM) to respond to client (which is on the host machine). All methods return same:

Host '10.0.2.2' is not allowed to connect to this MySQL server

I have ensured proper port forwardind. I also ensured, that in my.cnf I have folowing lines:

skip-external-locking
bind-address = 0.0.0.0

This did not work to me. I also tried to play a bit as folowing:

bind-address = 10.0.2.2

But this also did not work to me - server just could not start.

Any ideas, where I am wrong?

UPDATE. I did not check privilegies for root@% as in How do I change the privileges for MySQL user that is already created?

SOLVED.

defance
  • 313

1 Answers1

38

The root account's localhost-only in the vast majority of default installations, are you certain you've allowed it to log in from the other system? From the MySQL reference manual:

it means that there is no row in the user table with a Host value that matches the client host

So, there's no % or 10.0.2.2 in the Host column at all. Check your current config:

select user,host from mysql.user where user='root';

You likely want to create a new root entry with the same password as you have now.

create user 'root'@'10.0.2.2' identified by 'yourpassword';
grant all privileges on *.* to 'root'@'10.0.2.2' with grant option;
flush privileges;
Shane Madden
  • 116,404
  • 13
  • 187
  • 256