0

I have a VM (Ubuntu 18.04 Server) and mysql installed on it and running on port 3306. I think it's quite essential to show the whole config, here it is:

[mysqld_safe]
socket                  = /var/run/mysqld/mysqld.sock
nice                    = 0

[mysqld]
server-id               = 1
user                    = mysql
pid-file                = /var/run/mysqld/mysqld.pid
log-bin                 = /var/log/mysql/mysql-bin.log
socket                  = /var/run/mysqld/mysqld.sock
sync_binlog             = 1
binlog_format           = ROW
port                    = 3306
basedir                 = /usr
datadir                 = /var/lib/mysql
tmpdir                  = /tmp
lc-messages-dir         = /usr/share/mysql
skip-external-locking
bind-address            = 192.168.1.91
key_buffer_size         = 16M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8
myisam-recover-options  = BACKUP

query_cache_limit       = 1M
query_cache_size        = 16M


log_error = /var/log/mysql/error.log
expire_logs_days        = 7
max_binlog_size         = 500M

The address of the virtual machine is 192.168.1.91. The address of the hostmachine is 192.168.1.118. I ssh to the virtual machine and issue the following command:

sudo mysql -u root -p

Then I issue a series of commands shown here in the first section. It creates a new admin-like user with all the privileges necessary.

Now I quit and try to log in like so from the vm:

sudo mysql -u vScopeUserName -h 192.168.1.91 -p

It works.

If I try to log in like so from the vm:

sudo mysql -u vScopeUserName -h localhost -p

It works.

Now if I try to log in like so from the host machine (whose ip is 192.168.1.118):

sudo mysql -u vScopeUserName -h 192.168.1.91 -p

It errors out with:

ERROR 1130 (HY000): Host '192.168.1.118' is not allowed to connect to this MySQL server

I would be extremely grateful if you would help me figure out the reason behind this error. What am I doing wrong?! I've googled through a bunch of stuff on the internet and but all I tried did not work, I'm still getting the same error.

Blue
  • 22,608
  • 7
  • 62
  • 92
GoBear
  • 518
  • 1
  • 5
  • 19
  • `user@localhost` and `user@%` are 2 separate users. You need to ensure that you've created the later, for use from another machine (Or for more security, include the full IP address: `user@192.168.1.91`.) – Blue Oct 05 '18 at 18:25
  • @FrankerZ Well I've created a user issuing this command `CREATE USER 'vScopeUserName'@'192.168.1.91' IDENTIFIED BY 'password';` Is that what you mean by the later? – GoBear Oct 05 '18 at 18:29
  • 1
    Sorry, `user@192.168.1.118` or wildcard for the entire subnet: `user@192.168.1.%` or `user@192.168.1.0/255.255.255.0` – Blue Oct 05 '18 at 18:30
  • @FrankerZ oh I see, let me try. – GoBear Oct 05 '18 at 18:33
  • Yes! It worked, well I have to admit it was my first time configuring it so yeah, now I can clearly see what exactly I happened to misunderstand. Thank you ever so much! – GoBear Oct 05 '18 at 18:47

0 Answers0