By default,remote access to mysql database is disabled in ubuntu.Following is how to enable this in ubuntu+mysql5.
1.Edit etc/mysql/my.cnf:

sudo gedit /etc/mysql/my.cnf

change bind-address to your IP address,make it look like this:

[mysqld]
#
# * Basic Settings
#
default-character-set=utf8
default-storage-engine=INNODB

bind-address    = 192.168.1.107

user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
language        = /usr/share/mysql/english
skip-external-locking

2.Log in mysql with root user and run:

grant all on sonardb.* to sonar@'%' identified by '123456';
grant all on sonardb.* to sonar@localhost identified by '123456';

Change “sonardb” to the database_name your want to remote access to.”sonar” is the user_name,and ’123456′is the password.