Home > Database > Mysql Tutorial > How to use SSH channel to access mysql

How to use SSH channel to access mysql

王林
Release: 2020-01-27 20:20:15
forward
2202 people have browsed it

How to use SSH channel to access mysql

The method of using SSH channel to connect to remote Mysql is as follows:

1. Establish SSH channel

Just type the following command locally :

ssh -fNg -L 3307:127.0.0.1:3306 myuser@remotehost.com
Copy after login

Recommended online learning video tutorial: mysql video tutorial

2. Connect to Mysql

Now, you can connect locally The remote database is just like accessing the local database.

mysql -h 127.0.0.1 -P 3307 -u dbuser -p db
Copy after login

Or use Mysql Query Brower to access the Client's 3307 port.

Similarly, use PHP to access:

<?php
$smysql = mysql_connect( "127.0.0.1:3307", "dbuser", "PASS" );
mysql_select_db( "db", $smysql );
?>
Copy after login

Recommended related articles and tutorials: mysql tutorial

The above is the detailed content of How to use SSH channel to access mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template