Termux 開啓ssh並配置openjdk 和mysql等等環境

Termux 一系列操作

可以到豌豆莢下載termux ,安裝到android 手機,最好手機有root 權限。
下面對命令進行記錄。。
一.開啓ssh:
1.更新包

apt update
apt upgrade

2.安裝openssh

apt install openssh

安裝之後可以進行操作。。

// 查看用戶
whoami
//修改密碼
passwd

3.開啓ssh 服務

sshd #-p 可以指定端口號(默認8022)

4.查看ip(注意手機和電腦要在局域網內)

ifconfig

5.使用putty 登陸
putty 網盤地址:

https://pan.baidu.com/s/1zJD5wafBIjQOE6Oe3ToOng 
提取碼:2bnb

下載後直接在電腦桌面雙擊運行
頁面輸入:
在這裏插入圖片描述
二.安裝linux 系統:
下載Anlinux android 軟件

// A code block
百度雲: https://pan.baidu.com/s/1THW5_GNxTKlTvysMULlNZA
提取碼:bucb

安裝到手機上打開軟件,複製需要安裝的linux 的系統鏈接,到termux 的命令窗口下載。
這裏我下載的是ubuntu 下載完成後輸入:

// A code block
開啓linux 命令:
./start-ubuntu.sh

Linux 開啓成功。
在這裏插入圖片描述

三,linux 系統相關配置安裝:
1.更新配置:

// A code block
apt update  
apt upgrade
apt  install sudo
apt install yum
apt install net-tools

2.安裝openjdk1.8

  // 更新update package
      sudo apt-get update  
   //安裝jdk
    sudo apt-get install openjdk-8-jdk

在這裏插入圖片描述
jdk 安裝完畢。
4.安裝mysql
參考博客(https://www.jb51.net/article/172456.htm)
(1) 安裝執行安裝命令(一直點擊y)

apt install mysql-server

在這裏插入圖片描述
(2)設置基本配置
1.安裝驗證密碼插件。
2.設置root管理員在數據庫中的專有密碼。
3.隨後刪除匿名賬戶,並使用root管理員從遠程登錄數據庫,以確保數據庫上運行的業務的安全性。
4.刪除默認的測試數據庫,取消測試數據庫的一系列訪問權限。
5.刷新授權列表,讓初始化的設定立即生效

// A code block
 //1.安裝驗證密碼插件:
 mysql_secure_installation  --執行此命令後,初次運行mysql 沒有密碼,直接回車。

在這裏插入圖片描述
2.對於操作後面的操作我直接粘貼代碼(虛擬機環境崩了。。)

// A code block
root@ubuntu-virtual-machine:~# mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin? #要安裝驗證密碼插件嗎?

Press y|Y for Yes, any other key for No: N # 這裏我選擇N
Please set the password for root here.

New password: #輸入要爲root管理員設置的數據庫密碼

Re-enter new password: #再次輸入密碼

By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y #刪除匿名賬戶
Success.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N #禁止root管理員從遠程登錄,這裏我沒有禁止

... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y #刪除test數據庫並取消對它的訪問權限
- Dropping test database...
Success.

- Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y #刷新授權表,讓初始化後的設定立即生效
Success.

All done!

接下來使用 mysql -u root -p 可進入數據庫。
3.設置mysql允許遠程訪問

// A code block
首先編輯 /etc/mysql/mysql.conf.d/mysqld.cnf 配置文件
vim /etc/mysql/mysql.conf.d/mysqld.cnf 或者使用xshell 來直接修改文件
註釋掉bind-address = 127.0.0.1

4.設置用戶授權

// A code block
mysql -u root -p
mysql> grant all on *.* to root@'%' identified by '你的密碼' with grant option;
mysql> flush privileges; # 刷新權限
mysql> exit

最後重啓Mysql

// A code block(具體命令有點忘了。)
systemctl restart mysql
或者
sudo service mysql start 
(好像是這個)

使用遠程工具Navicat 連接。
接下來是配置ngrok 內網穿透:
1.安裝git(好像也不用裝,直接裝golang 就可以) 防止報錯,裝一下。

sudo apt-get update
sudo apt-get install git
sudo apt-get install golang-go

2.剩下的按照官網的文檔來:(termux 虛擬機中的ubuntu 內核爲arm64)這裏我就扔一個百度雲。

// A code block
https://pan.baidu.com/s/1KpG_QrsEmx14dyc7_voXyw
密:ibrt
下載後解壓:
tar -zxvf ngrok-stable-linux-arm64.tgz

剩下的自己到ngrok 官網找如何配置:

https://dashboard.ngrok.com/get-started(ngrok 官網)

最後啓動成功。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章