access denied when mysql to localhost using public ip I would like to use the command below to connect to my Mac's local database (xx.xxx.xxx.xxx is the Mac's ip address)

mysql -u cgao -h xx.xxx.xxx.xxx -p


and I got the error message: 

ERROR 1045 (20000): Access denied for user 'cage'@'dhcp-xx-xxx-xx-xxx.dyn.mycompany.com' (using password: YES)


But it will succeed when I enter the same command in another computer. How can I solve it? Can I only use localhost or 127.0.0.1 to local machine?

I feel it is somehow related to the dynamic ip address in my company. But I didn't find the exact answer on the web. Can someone elaborate the reason and share suggestions?
If you want to login to MySQL on the local machine using the IP address do this

mysql -u cgao -h xx.xxx.xxx.xxx -P3306 --protocol=tcp -p


This force a TCP/IP connection locally