The Pagoda panel installs the MySQL database and uses the intranet penetration tool to achieve remote access to the public network.

Preface

The simple operability of the Pagoda Panel reduces the difficulty of operation and maintenance, and simplifies the tedious configuration of the Linux command line. In the following simple steps, you can quickly build a MySQL database service and achieve remote access to the public network through the Pagoda Panel + cpolar.

1.Mysql service installation

We open the Pagoda panel, click on the database, and then click to install the mysql service,

image-20230308114036221

Just choose quick installation, the version is default

image-20230308114155813

Then wait for the installation to complete

image-20230308115355811

2.Create database

After installation, change the root password. This root password is also the password entered when logging in to mysql.

image-20230308135246031

After the modification, we test adding a database. The Pagoda panel allows you to create a mysql database directly on the page, set the user name and password, set the access permission to everyone, and then submit it.

image-20230308135942833

After the submission is successful, we can see that a database appears in the list.

image-20230308140156762

Then we open a port 3306 on the Pagoda panel security page

image-20230308144501496

3.Install cpolar

Open the Pagoda Terminal command window and use the cpolar installation script:

curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash

image-20230303183721806

token authentication

Log in to the cpolar official website www.cpolar.com , click on the left 验证to view your authentication token, and then paste the token into the command line

cpolar authtoken xxxxxxx

20230111103532

Add services to the system

sudo systemctl enable cpolar

Start cpolar service

sudo systemctl start cpolar

Select security in the Pagoda panel. Then open port 9200

image-20230303184430176

Then the cpolar management interface will appear on the LAN ip+:9200 port, and then use the account registered on the official website to log in. If you have not registered, you can click the account below to register for free.

image-20230303184618711

3.2 Create HTTP tunnel

Click Tunnel Management on the left dashboard - Create Tunnel. Since the default port in mysql is 3306, we need to create a tcp tunnel pointing to port 3306:

  • Tunnel name: Customizable, be careful not to repeat it
  • Protocol: tcp
  • Local address: 3306
  • Domain name type: Choose a random domain name
  • Region: Select China VIP

Click创建

image-20230308143442570

After the creation is successful, open the online tunnel list and view the public network tcp address.

image-20230308143555743

4.Remote connection

Next, we use the database connection tool navicat to test the connection. The address uses the public network address above. Clicking on the test connection indicates success.

image-20230308144715059

5. Fixed TCP address

Since the tunnel created above is a random address tunnel, the address will change within 24 hours. In order to make the connection more stable, a fixed TCP address is required.

It should be noted that configuring a fixed TCP port address requires upgrading cpolar to the Professional Edition package or above.

5.1 Reserve a fixed public network TCP port address

Log in to the cpolar official website backend, click Reserve on the left, and select the reserved TCP address.

  • Region: Select China VIP
  • Description: Notes, which can be customized

Click to keep

image-20230308145647536

After the address is successfully reserved, the system will generate the corresponding fixed public address and copy it.

image-20230308145717172

5.2 Configure fixed public network TCP port address

Log in to the cpolar web ui management interface again, click Tunnel Management >> Tunnel List on the left dashboard, find the mysql tunnel created above, and click Edit on the right.

image-20230308145818981

Modify the tunnel information and configure the successfully reserved fixed TCP address into the tunnel.

  • Port type: modified to fixed tcp port
  • Reserved tcp address: fill in the successfully reserved address

Click to update

image-20230308150103255

After the tunnel is updated successfully, click the status online tunnel list on the left dashboard to find the tunnel that needs to be edited. You can see that the public network address has been updated to a fixed TCP address.

image-20230308150143666

Open the database connection tool again and use our fixed tcp address to connect to achieve remote connection.

image-20230308151550924

Guess you like

Origin blog.csdn.net/qyj19920704/article/details/135129778