-4

I'm working on this for 4 days and I know it is all over google, but I did all the required stuff but still no connection.

I created to 2 vagrant boxes, one for web server and one for mysql.

web: 192.168.50.50 mysql: 192.168.40.40

I edited the /etc/mysql/my.cnf file and placed:

 bind-address        = 192.168.40.40

now I created a user named "bob" with password "12345" with all permissions.

CREATE USER 'bob'@'localhost' IDENTIFIED BY '12345';

GRANT ALL PRIVILEGES ON *.* TO 'bob'@'192.168.50.50';

and flushed privileges

now I can see all is good in the database:

 +--------------+------------------+
| Host          | User             |
+---------------+------------------+
| %             | root             |
| 192.168.50.50 | bob              |
| 127.0.0.1     | root             |
| ::1           | root             |
| localhost     | debian-sys-maint |
| localhost     | root             |
| mysql         | root             |
+---------------+------------------+

but when I try to connect threw the webserver:

mysql -ubob -h192.168.40.40 -p12345

I get this:

ERROR 1045 (28000): Access denied for user 'bob'@'192.168.40.1' (using password: YES)

what is that ip "192.168.40.1" who is he and how did he appeared? and how do I fix that?

Bart De Vos
  • 17,761
  • 6
  • 62
  • 81
Tzook Bar Noy
  • 145
  • 1
  • 5

1 Answers1

4

This is your accessing from your machine as bob.

ERROR 1045 (28000): Access denied for user 'bob'@'192.168.40.1' (using password: YES)

You created a local user named bob but then you also need to create a bob user that can be user remotely see as follows and try to log in.

CREATE USER 'bob'@'192.168.40.1' IDENTIFIED BY '12345';
GRANT ALL PRIVILEGES ON *.* TO 'bob'@'192.168.40.1';

https://stackoverflow.com/questions/16287559/mysql-adding-user-for-remote-access

  • 2
    using 'bob'@'%' may be convenient but it's not good practice especially when you know that bob is connecting from 192.168.40.1. It would be very much better to use 'bob'@'192.168.40.1'. – user9517 Sep 06 '15 at 15:53