0

I have an Ubuntu 18.04 Desktop 64 bit host machine.

On this host machine, I have used VirtualBox to create an Ubuntu 18.04 Server 64 bit VM, and have installed MySQL on it, created a MySQL user, a database, and a table.

I have set the network adaptor in this VM to Bridged Adaptor.

On the host machine, if I type:

telnet <VM IP Address> <MySQL port number>

I get the following error message:

telnet: Unable to connect to remote host: Connection refused

What have I missed out in the configuration?

2
  • 2
    what is the output of netstat -anutp | grep :<MySQL port number> on the Ubuntu server? this will show you where MySql is listening.
    – Zina
    Commented Oct 22, 2019 at 21:46
  • @Zina The output is tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 995/mysqld. The IP Address of the VM server is 192.168.0.19. Commented Oct 22, 2019 at 22:09

1 Answer 1

2

Your MySQL server inside the VM is bound only on localhost (127.0.0.1).

To connect from your desktop, you need it to be listening on the bridged network interface, though it's easiest just to have it listen on all interfaces.

Modify your /etc/mysql/my.cnf (or wherever your my.cnf can be found) so that you either uncomment or add the following line:

bind-address = 0.0.0.0

within the [mysqld] section so it looks like the following:

...
[mysqld]
bind-address     = 0.0.0.0
...

If you are having trouble finding your my.cnf, the places MySQL searches in Unix and Unix-Like Systems is:

File Name                Purpose
/etc/my.cnf              Global options
/etc/mysql/my.cnf        Global options
SYSCONFDIR/my.cnf        Global options
$MYSQL_HOME/my.cnf       Server-specific options (server only)
defaults-extra-file      The file specified with --defaults-extra-file, if any
~/.my.cnf                User-specific options
~/.mylogin.cnf           User-specific login path options (clients only)
DATADIR/mysqld-auto.cnf  System variables persisted with SET PERSIST or SE PERSIST_ONLY (server only)

Note some distributions also assign their own locations (e.g. /etc/mysql/mysql.conf.d/mysqld.cnf)

See https://dev.mysql.com/doc/refman/8.0/en/option-files.html for more information.

1
  • This fixed the problem. Thanks. Commented Oct 23, 2019 at 10:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .