I found this tutorial is quite helpful:
how-do-i-enable-remote-access-to-mysql-database-server
Unfortunately, I still get the following errors
chucheng@laptop:~$ mysql -ufoo -pcrap mysql.ucla.edu
ERROR 1044 (42000): Access denied for user 'foo'@'laptop' to...
After trying several solution, I finally realized that in the statement
GRANT ALL ON db_name.* TO foo@'%' IDENTIFIED BY 'PASSWORD';
you cannot skip "IDENTIFIED BY password".It turns out that you will "override" existing passwords with an empty password if you did not provide corresponding inputs.
Just in case that you still have problems:
Please make sure that
(1) Your bind-address in /etc/mysql/my.cnf has been changed to "real" IP.
(2) your port is listening
netstat -an | grep 3306
(3) You grant remote access permission to the user accounts.
p.s if you encounter any problems when login from localhost, instead of granting foo@'%', please grant foo@'localhost' as well.