
Android DeX is a powerful feature that transforms your Samsung device into a desktop-like environment. While it provides a great computing experience, it doesn’t natively support MySQL Server. However, you can achieve a similar setup by using Termux to install MariaDB, a MySQL-compatible database server.
This guide will walk you through installing, configuring, and running MySQL (via MariaDB) on Android DeX.
Why MariaDB Instead of MySQL?
MariaDB is an open-source fork of MySQL that retains full compatibility with MySQL commands, making it a great alternative. Unfortunately, MySQL itself is not available on Termux, but MariaDB works seamlessly in the same environment.
Prerequisites
Before we begin, ensure you have the following:
- A Samsung device that supports Android DeX
- An active internet connection
- Termux installed (download it from F-Droid or Google Play Store if available)
Step 1: Install Termux and Update Packages
To get started:
- Install Termux: Open the Play Store or F-Droid and install the Termux app.
- Open Termux and update its package list to ensure you’re working with the latest versions:
pkg update && pkg upgrade -y
Step 2: Install MariaDB (MySQL Alternative)
Now, install MariaDB, which functions as a MySQL-compatible database server.
Run the following command in Termux:
pkg install mariadb -y
This will install MariaDB and all necessary dependencies.
Step 3: Initialize the Database
After installation, you need to initialize the MariaDB database with:
mysql_install_db
This command sets up the database structure and prepares it for first-time use.
Step 4: Start the MariaDB Server
To start the database server, use:
mysqld_safe --datadir=$PREFIX/var/lib/mysql &
This will run MariaDB in the background, allowing you to interact with it like a standard MySQL server.
Step 5: Secure the Database and Set Up Root Password
By default, MariaDB installs without a password, making it insecure. To fix this:
- Log into the database as the root user:
mysql -u root
- Set a secure root password:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpassword'; FLUSH PRIVILEGES; EXIT;
Replaceyourpassword
with a strong password of your choice.
Step 6: Enable Auto-Start for MariaDB
If you want MariaDB to start automatically when you launch Termux, add this command to your .bashrc
file:
echo "mysqld_safe --datadir=$PREFIX/var/lib/mysql &" >> ~/.bashrc
Now, every time you start Termux, MariaDB will launch automatically.
Step 7: Connect to Your Database
Whenever you need to access MySQL (MariaDB), simply run:
mysql -u root -p
Then, enter your root password when prompted.