SQL queries in MySQL using phpseclib <p>I am trying to connect to MySQL database on a remote server and I could successfully connect to the server and login to the MySQL database. But now i need to run few SQL queries on the database tables but facing the error : ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES).</p> <p>I am not sure if the SQL queries are of correct syntax? Also do i need to connect to the server every time i need to run SQL queries? Please provide me with some inputs. Thanks.</p> <pre><code> /* SUCCESS */ $ssh = new Net_SSH2('XX.XXX.XX.XXX'); if (!$ssh-&gt;login('root', 'password')) { exit('Login Failed'); } echo $ssh-&gt;exec('pwd'); /* SUCCESS */ if (!$ssh-&gt;exec('mysql -h localhost -u root -pDataBaseName \r\n')){ exit('Login to MySQL Failed'); }else{ echo "Login to MySQL Success"; } /* ERROR - facing error in this code*/ echo $ssh-&gt;exec('mysql -h localhost -u root -pDataBaseName -e "SELECT * FROM cmu_util_all"'); </code></pre>