The AppGini Blog
A few tips and tricks to make your coding life a tiny bit better.

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

MySQL User 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:

  1. Checks for MySQL — verifies that the mysql command is available. If it isn’t, it asks you to provide the full path to the executable.
  2. Prompts for admin credentials — asks for your MySQL username (defaults to root) and password (defaults to empty, no -p flag is passed if blank).
  3. Connects and lists databases — tests the connection and displays all existing databases so you can choose or decide on a name.
  4. Collects new user details — prompts you for the new username, password, and the database to grant access to.
  5. Creates the database if missing — uses CREATE DATABASE IF NOT EXISTS so you don’t have to pre-create the database manually.
  6. Creates the user and grants full privileges — runs CREATE USER, GRANT ALL PRIVILEGES, and FLUSH PRIVILEGES in sequence.
  7. 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.

  1. Download create_mysql_user.bat
  2. Open Command Prompt (cmd) or PowerShell
  3. Navigate to the folder containing the script
  4. Run:
    1
    
    create_mysql_user.bat
    
  5. Follow the prompts

Tip: If mysql is not in your system PATH (e.g. you’re using a portable XAMPP install), the script will ask you to provide the full path to mysql.exe, such as C:\xampp\mysql\bin\mysql.exe.


Linux / macOS

  1. Download create_mysql_user.sh
  2. Open a terminal and navigate to the folder containing the script
  3. Make it executable:
    1
    
    chmod +x create_mysql_user.sh
    
  4. Run:
    1
    
    ./create_mysql_user.sh
    
  5. 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 USER and GRANT privileges
  • Windows CMD / PowerShell or a Bash-compatible shell (Linux, macOS, WSL)

That’s it. One script, one run, zero SQL to remember.