Skip to content

Instantly share code, notes, and snippets.

@ans1genie
Created September 5, 2024 10:47
Show Gist options
  • Save ans1genie/9e691ad1e6bd05c2b22aef5b2f11e422 to your computer and use it in GitHub Desktop.
Save ans1genie/9e691ad1e6bd05c2b22aef5b2f11e422 to your computer and use it in GitHub Desktop.
Creating a New MySQL/MariaDB User and Granting All Privileges

Creating a New MySQL/MariaDB User and Granting All Privileges

The provided SQL commands are used to create a new user in MySQL or MariaDB and grant that user all privileges. Here's what each line does:

  1. CREATE USER 'user'@'%' IDENTIFIED BY 'pwd';

    • This command creates a new user named user with the password pwd.
    • The @'%' part specifies that this user can connect from any host.
  2. GRANT ALL PRIVILEGES ON *.* TO 'user'@'%';

    • This command grants the user user all privileges on all databases and tables (*.*).
    • Essentially, the user user will have full control over the entire database server.

This combination of commands gives the new user complete administrative access to the MySQL or MariaDB server, which includes the ability to create, modify, and delete databases and tables, as well as manage other users.

Note: Granting all privileges to a user is a powerful action and should be done with caution, especially in a production environment, to prevent accidental or malicious damage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment