After installation mysql by default allows access from localhost. To access database from other IPs we have to do following steps:

  • in /etc/mysql/my.cnf remove or comment out line
    bind-address = 127.0.0.1"
  • grant remote access for username either from any IP:
    GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
  • or from selected IP:
    GRANT ALL PRIVILEGES ON *.* TO 'username'@'yourselectedIP' IDENTIFIED BY 'password' WITH GRANT OPTION;
  • restart service:
    sudo service mysql restart