Stop Memorizing MySQL Commands — Create Users Instantly with This CLI Wizard

Managing MySQL users shouldn’t require a cheat sheet. Whether you’re setting up a new project database or onboarding a developer, the standard approach means juggling multiple commands, remembering exact syntax, and hoping you don’t miss the FLUSH PRIVILEGES. Some developers reach for GUI tools like phpMyAdmin or HeidiSQL just for this single task — spinning up a full web server or installing a desktop app just to run a few SQL statements.
There’s a better way.
We’ve prepared a single, interactive CLI script — available for both Windows (.bat) and Linux/macOS (.sh) — that walks you through the entire process in a wizard-style interface. No arguments to memorize, no SQL syntax to recall, no app to install. Just run the script, answer the prompts, and you’re done.
What the Script Does
Both scripts follow the same step-by-step flow:
- Checks for MySQL — verifies that the
mysqlcommand is available. If it isn’t, it asks you to provide the full path to the executable. - Prompts for admin credentials — asks for your MySQL username (defaults to
root) and password (defaults to empty, no-pflag is passed if blank). - Connects and lists databases — tests the connection and displays all existing databases so you can choose or decide on a name.
- Collects new user details — prompts you for the new username, password, and the database to grant access to.
- Creates the database if missing — uses
CREATE DATABASE IF NOT EXISTSso you don’t have to pre-create the database manually. - Creates the user and grants full privileges — runs
CREATE USER,GRANT ALL PRIVILEGES, andFLUSH PRIVILEGESin sequence. - Confirms success — displays a clean summary of what was created.
Every step includes error checking. If anything fails — bad credentials, a permission issue, a duplicate user — the script exits immediately with a clear error message.
Download
| Platform | File |
|---|---|
| Windows | create_mysql_user.bat |
| Linux / macOS | create_mysql_user.sh |
How to Deploy and Use
Windows
No installation required. Just save the file and run it.
- Download
create_mysql_user.bat - Open Command Prompt (
cmd) or PowerShell - Navigate to the folder containing the script
- Run:
1create_mysql_user.bat - Follow the prompts
Tip: If
mysqlis not in your system PATH (e.g. you’re using a portable XAMPP install), the script will ask you to provide the full path tomysql.exe, such asC:\xampp\mysql\bin\mysql.exe.
Linux / macOS
- Download
create_mysql_user.sh - Open a terminal and navigate to the folder containing the script
- Make it executable:
1chmod +x create_mysql_user.sh - Run:
1./create_mysql_user.sh - Follow the prompts
Tip: The password prompts use silent input (
read -s), so your credentials won’t be visible on screen.
Example Session
Enter MySQL username [root]:
Enter MySQL password (press Enter for no password):
Connecting to MySQL...
Connected successfully!
Available databases:
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
Enter new MySQL username to create: alice
Enter password for new user:
Enter database name to grant privileges on: alice_app
Creating database if it doesn't exist...
Creating user 'alice' with access to database 'alice_app'...
========================================
SUCCESS!
========================================
User 'alice' has been created with:
- Password: ********
- Full privileges on database: alice_app
- Host: localhost
========================================
Requirements
- MySQL or MariaDB installed
- Admin credentials with
CREATE USERandGRANTprivileges - Windows CMD / PowerShell or a Bash-compatible shell (Linux, macOS, WSL)
That’s it. One script, one run, zero SQL to remember.