All     Ethical Hacking     Networking     Programming     OSINT

MySQL in Termux – Installation & Basic Commands

MySQL is a powerful database system used to store and manage data. With Termux, you can install MySQL directly on your Android phone and practice creating databases, tables, and running queries without a PC. Below are the installation steps and basic commands to get started.

Installation

Update Termux packages first:

pkg update && pkg upgrade -y

Install MariaDB (a drop-in replacement for MySQL):

pkg install mariadb -y

Initialize the database:

mysql_install_db

Start the MySQL server:

mysqld_safe &

Login to MySQL:

mysql -u root

Basic Commands

Show all databases:

SHOW DATABASES;

Create a new database:

CREATE DATABASE testdb;

Use a database:

USE testdb;

Create a table:

CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50));

Insert data into table:

INSERT INTO users (id, name) VALUES (1, 'Achik');

View table data:

SELECT * FROM users;

Exit MySQL:

EXIT;

Stop MySQL server:

mysqladmin -u root shutdown

Uninstall MariaDB:

pkg uninstall mariadb