I'm using phpseclib to connect to mysql database with php for my app. I can connect to mysql with workbench using TCP/IP over SSH without a problem but I can't connect my code to it. I'm creating a ssh connection first and then I start with mysql connections and querys but I have this error
mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES)
I've found some people using a command like "$ssh->exec('mysql -u user -p password') to connect to mysql but after that, how can I do all my querys? as I understand, the "exec" command is as send commands to the server console?
Here is my code, I hope you can help me: This is conexion.php
include('Net/SSH2.php');
include('remote_conexion.php');
$db_host="127.0.0.1";
$db_user="root";
$db_password=" ";
$db_name="mascotas";
$ssh = new Net_SSH2($host);
if (!$ssh->login($sftp_user, $sftp_password)) {
exit('Login Failed');
}
$connection = mysqli_connect($db_host, $db_user, $db_password, $db_name);
And this is remote_conexion.php (ignore the "sftp" things, I'm using that for manage files)
include('Net/SFTP.php');
$host="***.***.**.***";
$sftp_user="user";
$sftp_password="*******";
$port="22";
$sftp = new Net_SFTP($host);
if (!$sftp->login($sftp_user, $sftp_password)) {
exit('Login Failed');
}