Go to http://www.cnblogs.com/andy-do/archive/2013/04/06/3002541.html
mysql remote access denied problem
When connecting to MySql database remotely:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
remote connection refused;
Solution:
MySQL> use MySQL;
Database changed
MySQL> grant all privileges on *.* to 'yourUser'@'%' identified by 'yourPassword';
Query OK, 0 rows affected (0.00 sec)
*.* marks all tables under all databases ,'*'.* identifies all tables under database*
MySQL> grant all on *.* to 'yourUser'@'%' identified by 'yourPassword';
Query OK, 0 rows affected (0.00 sec)
% can be filled in The IP address or host name that is allowed to access, % indicates all IP
Flush privileges;
Query OK, 0 rows affected (0.00 sec)
Mysql> exit;