How to install MySQL on Android Termux and achieve public remote access with intranet penetration

Time:2023-10-14

preamble

Android as a mobile device, although not originally designed as a server, as technology advances we can configure Android as a productivity tool and turn it into an on-the-go Linux.

MariaDB is a replica of the MySQL relational database management system, developed by the community with commercial backing and intended to remain open source under the GNU GPL. One of the reasons for the development of this branch was that there was a potential risk of MySQL being closed-sourced after Oracle’s acquisition of MySQL, so the community used a branch to avoid this risk.

Next we install MariaDB(mysql) database on android phone termux in a few simple steps, and combine it with cpolar intranet penetration to realize remote connection access in public network environment.

1. Install MariaDB

Termux also officially packages MariaDB, so it’s easy to install:

pkg install mariadb

Verify that the installation was successful, and check the version information.

mysql --version

Version information appears to indicate successful installation

How to install MySQL on Android Termux and achieve public remote access with intranet penetration

Start the database, using Linux’s ownnohup command to start it in the background

nohup mysqld &

You can see the process PID number after startup

How to install MySQL on Android Termux and achieve public remote access with intranet penetration

If you want to close themysql, can be executed.

kill -9 PID

2. Install cpolar intranet penetration tool

After successfully installing MySQL database on Android termux, we continue to install cpolar on termux to do intranet penetration to create a secure tunnel to expose MySQL to the public network, so as to realize that we can also remotely connect to the MySQL database on termux under different networks.

cpolar does not require a public IP address, nor does it need a router, nor does it need to buy a cloud server. It supports http/https/tcp protocols and can be used free of charge without limiting traffic.

cpolar Official websitehttps://www.cpolar.com/

Create asources.list.dFolders of.

mkdir -p $PREFIX/etc/apt/sources.list.d

Add cpolar download source file

echo "deb [trusted=yes] http://termux.cpolar.com termux extras" >> $PREFIX/etc/apt/sources.list.d/cpolar.list

Update Warehouse

pkg update

Install cpolar

pkg install cpolar

Install the termux service, note.Remember to close and reboot termux after the installation is complete before it takes effect!!!!

pkg install termux-services

After rebooting termux, thenStart cpolar intranet penetration

sv up cpolar

Setting up boot-up

sv-enable cpolar

Also:Commands to stop the cpolar service

sv down cpolar

As well as.cpolar.yml main configuration file path location

$PREFIX/etc/cpolar/cpolar.yml

Then in the mobile browser we typehttp://localhost:9200You can see the cpolar web UI management interface.You can log in with the e-mail account you registered on the cpolar website.

How to install MySQL on Android Termux and achieve public remote access with intranet penetration

3. create secure tunnel mapping mysql

After logging in to the cpolar web UI management interface, we click on the left side of the dashboard of the tunnel management – create a tunnel, due to the default mysql connection is port 3306, so we want to create a tcp tunnel, pointing to port 3306:

  • Tunnel name: customizable, taking care not to repeat
  • Protocol: tcp
  • Local address: 3306 (mysql default port)
  • Domain type: select random domain name
  • Region: Select China VIP

strike (on the keyboard)establish

How to install MySQL on Android Termux and achieve public remote access with intranet penetration

Once created, open the online tunnel list to see the random public tcp address generated, copy it down andNote that tcp:// does not need to be copied

How to install MySQL on Android Termux and achieve public remote access with intranet penetration

4. Remote connection to the public network

Above we create a good public address, then we use the tool to connect remotely to test, this article uses a hot database connection tool softwarenavicatOpen the tool interface, enter our public address and the corresponding port, because the creation of the time did not set a password, so we do not need to fill in the password, click to test the connection, the connection is successful that normal.

Similarly, other connection tools are connected in the same way.

How to install MySQL on Android Termux and achieve public remote access with intranet penetration

5. Fixed remote connection address

Since we used free random temporary addresses when creating the tunnel above, the generated public address will change randomly within 24 hours. If we want the data tunnel between different devices to exist stably for a long time, we need to set it up further (since the fixed TCP tunnel will take up cpolar server resources for a long time, we have to include this service in the VIP program).

To establish a stable TCP data tunnel, you need to first go to the backend of the cpolar website to reserve a fixed TCP address.

How to install MySQL on Android Termux and achieve public remote access with intranet penetration

We logged into the backend of the cpolar website, clicked on Reservations on the left dashboard, and found theReserved TCP address

  • Region: select China VIP here, you can also select other regions
  • Description: Customizable notes

Click on the right side of thereservations

How to install MySQL on Android Termux and achieve public remote access with intranet penetration

With this information filled in, click on the right side of thereservationsbutton to fix the tunnel on the backend of the cpolar website. At this time cpolar will generate a tunnel tcp port

How to install MySQL on Android Termux and achieve public remote access with intranet penetration

Next we go back to the browser cpolar web ui management interface and open theTunnel List, find the random temporary TCP tunnel you created earlier and enter thecompilerPage.

How to install MySQL on Android Termux and achieve public remote access with intranet penetration

Port Type SelectionFixed TCP portsand then paste the tunnel port we got from the cpolar website into thereserved TCP addresscolumn, and then click below theupdatebuttons

How to install MySQL on Android Termux and achieve public remote access with intranet penetration

Then check the list of online tunnels again, you can find that the public address corresponding to mysql’s tunnel has changed to the fixed address reserved by our official website

How to install MySQL on Android Termux and achieve public remote access with intranet penetration

After configuring the public address of the remote MySQL to be fixed, let’s test connecting with a fixed public address, which also allows you to connect to termux MySQL remotely.

Now as long as we keep this tunnel online, we can remotely connect to Termux MySQL from this public address.

How to install MySQL on Android Termux and achieve public remote access with intranet penetration

Reprinted from cpolar polar cloud article:Android Termux Installation of MySQL, Intranet Penetration for Public Remote Access

Recommended Today

uniapp and applet set tabBar and show and hide tabBar

(1) Set the tabBar: uni.setTabberItem({}); wx.setTabberItem({}); indexnumberisWhich item of the tabBar, counting from the left, is indexed from 0.textstringnoButton text on tabiconPathstringnoImage PathselectedIconPathstringnoImage path when selectedpagePathstringnoPage absolute pathvisiblebooleannotab Whether to display uni.setTabBarItem({ index: 0, text: ‘text’, iconPath: ‘/path/to/iconPath’, selectedIconPath: ‘/path/to/selectedIconPath’, pagePath: ‘pages/home/home’ }) wx.setTabBarItem({ index: 0, text: ‘text’, iconPath: ‘/path/to/iconPath’, selectedIconPath: ‘/path/to/selectedIconPath’, pagePath: ‘pages/home/home’ }) […]