Termux 开启ssh并配置openjdk 和mysql等等环境

24 篇文章 1 订阅

Termux 一系列操作
可以到豌豆荚下载termux ,安装到android 手机,最好手机有root 权限。
下面对命令进行记录。。
一.开启ssh:
1.更新包

apt update
apt upgrade

2.安装openssh

apt install openssh


安装之后可以进行操作。。

// 查看用户
whoami
//修改密码
passwd
1
2
3
4
3.开启ssh 服务

sshd #-p 可以指定端口号(默认8022)
1
4.查看ip(注意手机和电脑要在局域网内)

ifconfig
1
5.使用putty 登陆
putty 网盘地址:

https://pan.baidu.com/s/1zJD5wafBIjQOE6Oe3ToOng 
提取码:2bnb
1
2
下载后直接在电脑桌面双击运行
页面输入:

二.安装linux 系统:
下载Anlinux android 软件

// A code block
百度云: https://pan.baidu.com/s/1THW5_GNxTKlTvysMULlNZA
提取码:bucb
1
2
3
安装到手机上打开软件,复制需要安装的linux 的系统链接,到termux 的命令窗口下载。
这里我下载的是ubuntu 下载完成后输入:

// A code block

获取root

termux-chroot


开启linux 命令:
./start-ubuntu.sh
1
2
3
Linux 开启成功。


三,linux 系统相关配置安装:
1.更新配置:

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

1
2
3
4
5
6
7
2.安装openjdk1.8

  // 更新update package
      sudo apt-get update  
   //安装jdk
    sudo apt-get install openjdk-8-jdk
1
2
3
4

jdk 安装完毕。
4.安装mysql
参考博客(https://www.jb51.net/article/172456.htm)
(1) 安装执行安装命令(一直点击y)

apt install mysql-server
1

(2)设置基本配置
1.安装验证密码插件。
2.设置root管理员在数据库中的专有密码。
3.随后删除匿名账户,并使用root管理员从远程登录数据库,以确保数据库上运行的业务的安全性。
4.删除默认的测试数据库,取消测试数据库的一系列访问权限。
5.刷新授权列表,让初始化的设定立即生效

// A code block
 //1.安装验证密码插件:
 sudo service mysql restart --重启mysql
 mysql_secure_installation  --执行此命令后,初次运行mysql 没有密码,直接回车。
1
2
3
4

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!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
接下来使用 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
1
2
3
4
4.设置用户授权

// A code block
mysql -u root -p
mysql> grant all on *.* to root@'%' identified by '你的密码' with grant option;
mysql> flush privileges; # 刷新权限
mysql> exit
1
2
3
4
5
最后重启Mysql

// A code block
sudo service mysql restart --重启mysql

1
2
3
使用远程工具Navicat 连接。
接下来是配置ngrok 内网穿透:
1.安装git(好像也不用装,直接装golang 就可以) 防止报错,装一下。

sudo apt-get update
sudo apt-get install git
sudo apt-get install golang-go
1
2
3
2.剩下的按照官网的文档来:(termux 虚拟机中的ubuntu 内核为arm64)这里我就扔一个百度云。

// A code block
https://pan.baidu.com/s/1KpG_QrsEmx14dyc7_voXyw
密:ibrt
下载后解压:
tar -zxvf ngrok-stable-linux-arm64.tgz
注册,然后启动即可。
 ./ngrok http 8080  启动命令。
1
2
3
4
5
6
7
剩下的自己到ngrok 官网找如何配置:

https://dashboard.ngrok.com/get-started(ngrok 官网)
1
最后启动成功。

接下来是配置tomcat 服务器:

// 到官网下载tomcat 服务器,用远程工具把服务器放手机上。
解压tomcat 的包
tar -zxvf tomcat.tar.gz

解压完成后,到tomcat 的bin 包下面用命令
./startup.sh
1
2
3
4
5
6
没问题就启动成功了。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值