Set up a Linux server on your mobile phone

Keywords: Java Linux Database

Install SSHD

Install sshd

apt update && apt upgrade   # Update Terminal Package
apt install openssh

Start sshd

sshd

Set sshd self-start

echo "sshd" >> ~/.bashrc

Set User Name Password

Get the username, I have the username u0_a173 here

whoami
u0_a173

Set Password

passwd

Remote landing

ssh -p 8022 u0_a173@192.168.100.99

My user name here is u0_a173 and my mobile ip address is 192.168.100.99

Changing Tsinghua Source

sed -i 's@^\(deb.*stable main\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/termux-packages-24 stable main@' $PREFIX/etc/apt/sources.list

sed -i 's@^\(deb.*games stable\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/game-packages-24 games stable@' $PREFIX/etc/apt/sources.list.d/game.list

sed -i 's@^\(deb.*science stable\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/science-packages-24 science stable@' $PREFIX/etc/apt/sources.list.d/science.list

apt update && apt upgrade   # Update Terminal Package

Mount Storage Card

termux-setup-storage

Install VIM

pkg install vim

Modify Greetings

vim $PREFIX/etc/motd

Install java

Unzip the downloaded jdk package to usr/local/java

tar xJvf jvdroid_termux_openjdk_11.0.1.tar.xz -d $PREFIX/local/java

Configure Environment Path

echo "export PATH='$PATH:$PREFIX/local/java/bin'" >> ~/.bashrc
echo "export LD_LIBRARY_PATH='$PREFIX/local/java/lib:$PREFIX/local/java/lib/jli'" >> ~/.bashrc

test

java -version

Install MariaDB

install

pkg install mariadb

Configure MariaDB

mysql_install_db

Start MariaDB Server

mysqld

or

mysqld_safe -u root &

mysqld_safe runs with the root user;'&'will run in the background.
After the start is complete, the session remains alive and, like debug debugging, only a new session can be created.

Access database

To access the MariaDB database server, enter:

mysql -u root -p

However, the MariaDB database server, by default, does not have a password and only needs to enter the following commands to log in:

mysql

By default, you can set a password for the root account:

SET password FOR root@localhost = password('root');

Configure MariaDB remote login

Sometimes, for development or ease of operation, you can use a computer to remotely access and manage databases on your mobile phone. By default, MariaDB only allows local logins for security purposes. If you want to turn on remote connections, you can configure the following.

Create a user who can log on remotely:

CREATE USER 'username'@'%' IDENTIFIED BY 'password';

The%wildcard character indicates the creation of an accessible user for the external network.

User authorization:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root User's password' WITH GRANT OPTION;

If you want to grant the user appropriate permissions to operate on all databases and tables, you can use a * representation, such as.

Refresh Authorization:

flush privileges;

With the above configuration, other devices in the LAN can log into the database in the mobile phone to operate.

Note: Since the mysqld.cnf configuration file is not found in my.cnf.d directory, the option to bind-address without modification is also available for remote login.

Add MariaDB Self-Start

echo "mysqld" >> ~/.bashrc

Stop MariaDB Server

To stop the MariaDB server, enter:

$ pkill mysql

Alternatively, use the word "MySQL" to take its process ID, use the command grep, and kill them kill-9 [ID], -9 is to send a termination signal.

To find the process ID of execution:

$ ps aux | grep mysql

Once you have ID s, kill them:

$ kill -9 15423

Optional, but recommended: Secure MariaDB
The installation of MariaDB is working properly, and we don't have to worry about security if we only intend to use it. Instead, if you want to ensure it through good habits, you can do so. To do this, do:

$ mysql_secure_installation

This will provide you with a wizard that will help you ensure that MySQL is installed: enter your password, remove test privileges, and so on.

Install CentOS

1. Configure proot to simulate sudo permissions

$ pkg install proot
$ termux-chroot

2. Configure wget to download files

$ pkg install wget

3. Install centos command (tortoise speed waiting for installation to download.......... --=-= - = -- [You can also use Anlinux software copy command to install]

$ mkdir CentOS && cd CentOS && pkg install wget openssl-tool proot -y && hash -r && wget https://raw.fastgit.org/EXALAB/AnLinux-Resources/master/Scripts/Installer/CentOS/centos.sh && sed -i 's/githubusercontent.com/fastgit.org/' centos.sh && bash centos.sh && rm centos.sh

Attached, if you install the GUI linux system Ubuntu, use the following command

$ mkdir Ubuntu && cd Ubuntu && pkg install wget openssl-tool proot -y && hash -r && wget https://raw.fastgit.org/EXALAB/AnLinux-Resources/master/Scripts/Installer/Ubuntu/ubuntu.sh && sed -i 's/githubusercontent.com/fastgit.org/' ubuntu.sh && bash ubuntu.sh && rm ubuntu.sh

4. Start centos, enter directory and start CentOS

$ ls
$ ./start-centos.sh

Posted by Rusnoff on Wed, 29 Sep 2021 09:25:18 -0700