When running mysqld on a VirtualBox guest OS of Ubuntu Linux, connection was being refused.
Fixed by changing the bind-address value to 0.0.0.0 in mysqld.cnf
Command (edit as root with nano):
user@ubuntu:/etc/mysql/mysql.conf.d$ sudo nano mysqld.cnf
[mysqld] ... bind-address = 0.0.0.0
The next problem was error 1130 (access denied).
Fixed this by enabling password authentication:
user@ubuntu:~$ sudo mysql -u root -p -h localhost -P 3306 Enter password: ... mysql> use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> GRANT ALL ON *.* to user@'%' IDENTIFIED BY 'password'; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) mysql> exit Bye user@ubuntu:~$