How to use MySQL in Termux

Install MySQL

To install MySQL in Termux, open the Termux terminal and type the following command:
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:
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:
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: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.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top