A simple, automated Bash script to set up MariaDB (MySQL) on Termux Android. This script handles installation, database initialization, and creates a convenient shortcut (startsql) to manage the server and client connection in one go.
- Auto-Update: Automatically updates and upgrades Termux packages.
- Installation: Installs the latest stable version of MariaDB.
- Initialization: Runs
mysql_install_dbto set up the default data directory (only if not already present). - Shortcut Creation: Adds a permanent
startsqlalias to your.bashrc. - Smart Launch: The
startsqlcommand checks if the server is already running to prevent "Address already in use" errors.
- Termux App: Use the F-Droid version of Termux (Play Store version is deprecated).
- Internet Connection: Required to download packages.
Set up everything with a single command. Open Termux and run:
pkg install curl -y && bash <(curl -fsSL https://raw.githubusercontent.com/Adish08/TxSQL/refs/heads/main/setup.sh)- Installs
curl(if missing). - Downloads the
setup.shscript from the repository. - Executes the script immediately.
After the installation script completes, you’ll see a success message.
To activate the new command instantly:
source ~/.bashrc(Or simply close and reopen Termux)
Use the single-word command:
startsql- If server is stopped: Starts
mysqld_safein the background, waits 4 seconds, then logs you in. - If server is running: Skips startup and logs you in directly.
- Default Login: User
root, password prompt (usually empty — press Enter).
The setup.sh script performs:
- System Update: Runs
pkg update && pkg upgrade. - Package Install: Installs MariaDB.
- Database Setup: Checks for
$PREFIX/var/lib/mysql/mysql; if missing, performs initialization. - Bash Config: Appends the
startsqlfunction to your~/.bashrc.
After installation, you can secure your MariaDB setup by setting a root password.
Make sure MariaDB is running:
startsql(Logs you into the MariaDB shell)
Inside the MariaDB prompt, run:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('your_password_here');Replace your_password_here with your desired password.
FLUSH PRIVILEGES;EXIT;Next time you use:
startsqlIt will prompt for the password you set.
Feel free to fork the repository and submit pull requests with improvements.
Maintained by Adish08