Install MySQL
To install MySQL in Termux, open the Termux terminal and type the following command:
This command will install the MariaDB package, which is a community fork of MySQL.
pkg install mariadb
This command will install the MariaDB package, which is a community fork of MySQL.
Start the MySQL Server
After installing MariaDB, you can start the MySQL server by typing the following command:
This command will start the MySQL server and create a new MySQL prompt.
mysqld
This command will start the MySQL server and create a new MySQL prompt.
Log in to MySQL
To log in to MySQL, type the following command:
This command will log you into the MySQL server as the root user.
mysql -u root
This command will log you into the MySQL server as the root user.
Manage Databases
Once you’re logged in to MySQL, you can manage databases using SQL commands. Here are some common commands:
To create a new database, type the following command:
To switch to a different database, type the following command:
To show a list of all databases, type the following command:
To show the structure of a database, type the following command:
To exit MySQL, type the following command:
To create a new database, type the following command:
CREATE DATABASE database_name;
To switch to a different database, type the following command:
USE database_name;
To show a list of all databases, type the following command:
SHOW DATABASES;
To show the structure of a database, type the following command:
SHOW TABLES;
To exit MySQL, type the following command:
exit;
Conclusion
Using MySQL in Termux allows you to manage databases directly on your Android device. By following the steps outlined in this guide, you can install MySQL, start the MySQL server, log in to MySQL, and manage databases using SQL commands.