Install and configure MySQL on the pagoda panel to easily manage the database [public network remote access]

foreword

The simple operability of the pagoda panel reduces the difficulty of operation and maintenance, and simplifies the tedious configuration of the Linux command line. The following simple steps can quickly build a mysql database service and realize 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 on the install mysql service,

image-20230308114036221

You can choose the fast installation, the version defaults

image-20230308114155813

Then wait for the installation to complete

image-20230308115355811

2. Create a 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 to add the database. The pagoda panel provides that you can create a mysql database directly on the page, set the user name and password, set the access authority to everyone, and then submit

image-20230308135942833

The submission is successful and we can see that a database has appeared in the list

image-20230308140156762

Then we open a port 3306 on the security page of the pagoda panel

image-20230308144501496

3. Install cpolar intranet penetration

cpolar official website: https://www.cpolar.com/

  • Open the pagoda terminal command window and use cpolar to install the script:
curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash

image-20230303183721806

  • token authentication

Log in to the background of the cpolar official website, click on the left 验证to view your authentication token, and then paste the token in the command line

cpolar authtoken xxxxxxx

20230111103532

  • Add a service to the system
sudo systemctl enable cpolar
  • Start the cpolar service
sudo systemctl start cpolar

Select security in the pagoda panel. Then open port 9200

image-20230303184430176

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

image-20230303184618711

4. Create HTTP tunnel mapping mysql port

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
  • protocol: tcp
  • Local address: 3306
  • Domain 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

5. Remote connection

Next, we use the database connection tool navicat to test the connection. The address uses the above public network address. After clicking the test connection, it means success.

image-20230308144715059

6. 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 to configure a fixed TCP port address, cpolar needs to be upgraded to a professional package or above.

6.1 Reserve a fixed public network TCP port address

Log in to the background of the cpolar official website, click Reserved on the left, and select the reserved TCP address.

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

Click to keep

image-20230308145647536

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

image-20230308145717172

6.2 Configure a 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, 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 update

image-20230308150103255

After the tunnel is successfully updated, click the status online tunnel list on the left dashboard, find the tunnel to be edited, and 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 realize remote connection

image-20230308151550924

Guess you like

Origin blog.csdn.net/qq_41250372/article/details/130331283