Connect to a MySQL server over SSH in PHP
Eric,
I think you are out of luck on this one. You can either use the ssh extension in your PHP code, or if you have access to the server, you could try to create a ssh tunnel on the command-line.
You probably need special permissions to do that, though. It also looks like you don't have ssh access to this hosting account.
--Joao
Connect to a mysql database via SSH through PHP
I think you are out of luck on this one. You can either use the ssh
extension in your PHP code, or if you have access to the server, you
could try to create a ssh tunnel on the command-line.You probably need special permissions to do that, though. It also
looks like you don't have ssh access to this hosting account.
duplicate answered by @jpm
Setting up tunneling posted by @Ólafur Waage on Connect to a MySQL server over SSH in PHP
And this one for tunneling by @Sosy
shell_exec(“ssh -f -L 3307:127.0.0.1:3306 user@remote.rjmetrics.com sleep 60 >> logfile”);
$db = mysqli_connect(’127.0.0.1′, ‘sqluser’, ‘sqlpassword’, ‘rjmadmin’, 3307);
Using mysql via SSH (php)
$ssh_connection = ssh2_connect($ssh_server, $ssh_port);
ssh2_auth_password($ssh_connection, $ssh_user, $ssh_password);
$query="SET CHARACTER SET utf8; use ${db_database}; ${query};";
$query=str_replace('"', '\'', stripslashes($query));
$ssh_query="ssh -L 3307:${ssh_server}:${ssh_port}; echo \"${query}\" | mysql -u ${db_username} -h ${db_hostname} --password=${db_password}";
$result=ssh2_exec($ssh_connection, $ssh_query);
Related Topics
PHP: How to Read a .Txt File from Ftp Server into a Variable
PHP Password_Hash(), Password_Verify()
Why Is Register_Globals So Bad
Call to Undefined Function Oci_Connect()
Best Practice Multi Language Website
Why Is This PHP Call to Json_Encode Silently Failing - Inability to Handle Single Quotes
Prevent Sent Emails Treated as Junk Mails Using PHP Mail Function
Adding Months to a Date in JavaScript
How to Strip a Tag and All of Its Inner HTML Using the Tag'S Id
PHP Get All the Images from Url Which Width and Height ≫=200 More Quicker
How to Use a String as an Array Index Path to Retrieve a Value
How to Get the Current Page'S Full Url on a Windows/Iis Server
Read Each Line of Txt File to New Array Element
Why I'M Getting 500 Error When Using File_Get_Contents(), But Works in a Browser