Access Denied error when I try to access the asterisk db from php

I’m getting the following error:
Access denied for user ‘root’@‘localhost’ when I try the following commands:
$ssh_host=‘68.111.73.000’;
$username=‘root’;
$password=‘paswd’;

$sshconnection = ssh2_connect($ssh_host);
if (!$sshconnection) die(‘Connection failed’);

if (ssh2_auth_password($sshconnection, $username, $password)) {
echo “Authentication Successful!\n”;
} else {
die(‘Authentication Failed…’);
}
if ($tunnel = ssh2_tunnel($sshconnection, ‘255.255.255.255’, 3306))
echo “Tunnel OK”;
else
echo “Tunnel creation failed.”;
$link = mysql_connect(‘127.0.0.1’, ‘root’, ‘aasswrod’);
if (!$link) {
die('Could not connect: ’ . mysql_error());
}

I get through all the code until I get to the mysql_connect command where I get the error:
Access denied for user ‘root’@'localhost’
I’ve tried all the user/password combinations I can think of… I can accomplish this with ssh and putty using the username/password combination.

Thanks

if you tunnel in you won’t have access to 127.0.0.1 (on the lo interface), you will be effectively only on the localnet (on the eth? interface) you need to add a user with access from your local ip/network

Why not instead add a user with access from your remote ip?

Also your:-

if ($tunnel = ssh2_tunnel($sshconnection, ‘255.255.255.255’, 3306))

statement is un-bracketed to the point of confusion, you should fix that!

I think its just very strange that I can access the database on trixbox using mysql workbench and when I putty into the box using ssh I can access the database, but when I use ssh2 I can get into the box but I can’t get into the mysql database using the same user as when I access it with putty/mysql workbench. I’ve granted priveleges to my root user in mysql to be set up to have access on localhost, I’ve made sure of that. This is my first attempt at using ssh2 on php most other places I’ve work use shared hosting so its not an option, but now we’ve gone to a dedicated server, I’m working with it.