查看软件包
~ $ pkg list-all |grep mar
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
cmark-static/stable 0.30.2 aarch64
cmark/stable 0.30.2 aarch64
libmariadbcpp/stable 1.1.0-2 aarch64
mariadb-static/stable 2:10.6.7-1 aarch64
mariadb/stable 2:10.6.7-1 aarch64
marisa-static/stable 0.2.6 aarch64
marisa/stable 0.2.6 aarch64
proxmark3-git/stable 2022.06.27-636a8501-0 aarch64
proxmark3/stable 1:4.14831-2 aarch64
安装
~ $ pkg install mariadb
Testing the available mirrors:
[*] (1) https://mirrors.hit.edu.cn/termux/apt/termux-main: ok
[*] (1) https://mirrors.dgut.edu.cn/termux/apt/termux-main: bad
[*] (1) https://mirrors.nju.edu.cn/termux/apt/termux-main: ok
[*] (1) https://mirrors.cqupt.edu.cn/termux/apt/termux-main: ok
[*] (1) https://mirrors.aliyun.com/termux/termux-packages-24: ok
[*] (1) https://mirrors.bfsu.edu.cn/termux/apt/termux-main: ok
[*] (1) https://mirrors.pku.edu.cn/termux/termux-main/: ok
[*] (1) https://mirrors.ustc.edu.cn/termux/apt/termux-main: ok
[*] (1) https://mirror.iscas.ac.cn/termux/apt/termux-main: ok
[*] (1) https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main: ok
Picking mirror: (6) /data/data/com.termux/files/usr/etc/termux/chosen_mirrors/mirrors.ustc.edu.cn
Get:1 https://mirrors.ustc.edu.cn/termux/apt/termux-main stable InRelease [14.0 kB]
Get:2 https://mirrors.ustc.edu.cn/termux/apt/termux-main stable/main aarch64 Packages [429 kB]
Fetched 443 kB in 2s (209 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
mariadb
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 11.4 MB of archives.
After this operation, 159 MB of additional disk space will be used.
Get:1 https://mirrors.ustc.edu.cn/termux/apt/termux-main stable/main aarch64 mariadb aarch64 2:10.6.7-1 [11.4 MB]
Fetched 11.4 MB in 2s (6075 kB/s)
Selecting previously unselected package mariadb.
(Reading database ... 25304 files and directories currently installed.)
Preparing to unpack .../mariadb_2%3a10.6.7-1_aarch64.deb ...
Unpacking mariadb (2:10.6.7-1) ...
Setting up mariadb (2:10.6.7-1) ...
Initializing mysql data directory...
Installing MariaDB/MySQL system tables in '/data/data/com.termux/files/usr/var/lib/mysql' ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is u0_a340@localhost, it has no password either, but
you need to be the system 'u0_a340' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo
See the MariaDB Knowledgebase at https://mariadb.com/kb
You can start the MariaDB daemon with:
cd '/data/data/com.termux/files/usr' ; /data/data/com.termux/files/usr/bin/mysqld_safe --datadir='/data/data/com.termux/files/usr/var/lib/mysql'
You can test the MariaDB daemon with mysql-test-run.pl
cd '/data/data/com.termux/files/usr/mysql-test' ; perl mysql-test-run.pl
Please report any problems at https://mariadb.org/jira
The latest information about MariaDB is available at https://mariadb.org/.
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
客户端连接
mysql
# 创建用户
MariaDB [mysql]> create user 'root'@'%' identified by 'Q7.123';
Query OK, 0 rows affected (0.009 sec)
# 设置权限
MariaDB [mysql]> grant all privileges on *.* to 'root'@'%' identified by 'Q7.123';
修改密码(可选)
SET PASSWORD FOR 'u0_a340'@'localhost' = PASSWORD('Q7.123');
启动服务
加入到 ~/.bashrc
文件
# --------------- mysqld ----------------------
name='mysql'
if pgrep -x "mysqld_safe" >/dev/null
then
echo "[${name}]运行中..."
else
cd '/data/data/com.termux/files/usr' ; /data/data/com.termux/files/usr/bin/mysqld_safe --datadir='/data/data/com.termux/files/usr/var/lib/mysql' >/dev/null 2>&1 &
echo "[${name}]启动..."
fi