MySQL

How to Install and Configure MySQL on Windows 11 (Step-by-Step Guide)

MySQL is one of the most popular relational database management systems, and installing it on Windows 11 is straightforward. In this guide, we’ll walk through installing MySQL, configuring it, creating a database and user, and granting privileges.

1. Download and Install MySQL

  1. Download MySQL Installer
    • Go to the official MySQL Downloads page.
    • Choose MySQL Installer for Windows (preferably the Community Edition).
  2. Run the Installer
    • Double-click the downloaded .msi file.
    • Select “Developer Default” (includes MySQL Server, Workbench, and tools).
    • Click Next and follow the prompts.
  3. Configure MySQL Server
    • Choose the Standalone MySQL Server option.
    • Select the Default Authentication Method (Strong Password Encryption recommended).
    • Set the root password (make sure to remember it).
    • Click Next and complete the installation.

2. Verify MySQL Installation

  • Open Command Prompt and type:
mysql --version

You should see the installed MySQL version.

  • To log in:
mysql -u root -p

Enter the root password you set during installation.


3. Create a Database

Once logged in to the MySQL shell:

CREATE DATABASE myapp_db;

Check if it’s created:

SHOW DATABASES;

4. Create a New User

Create a user with a secure password:

CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword123';

5. Grant Privileges to the User

Give the new user full access to the myapp_db database:

GRANT ALL PRIVILEGES ON myapp_db.* TO 'myuser'@'localhost';
FLUSH PRIVILEGES;

6. Test the New User

Exit the MySQL shell:

EXIT;

Log in with the new user:

mysql -u myuser -p

Then select the database:

USE myapp_db;

If no errors appear, everything is set up correctly.


Conclusion

You’ve successfully installed MySQL on Windows 11, configured it, created a database, added a user, and granted privileges. You can now start building applications using this database!

Leave a Reply

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