I'm attempting to connect to a database through ssh tunnel. For whatever reason my database refuses to connect with 'my_user'@'localhost' but will connect with 'my_user'@'127.0.0.1'.
My php code specifies the host as 127.0.0.1 but when I run the code I'm not allowed to connect and receive.
Access denied for user 'my_user'@'localhost' (using password: YES)
I am able to connect via the command line with
mysql -u my_user -p -P 3307 -h 127.0.0.1
however if I use
mysql -u my_user -p -P 3307 -h localhost
I receive the error above
I found my problem. I was not specifying the port. My ssh tunnel is on port 3307 and the port was not specified in my dsn so it was trying to connect to the default port of 3306 which is probably why it was translating to localhost.