How can we help?
< All Topics

Creating a New User and Granting Permissions in MySQL on ServerStadium


Managing user access and permissions is a critical aspect of database administration in MySQL. Whether you’re running a MySQL server on a ServerStadium VM or dedicated server, it’s essential to understand how to create new users and define their privileges securely.

Creating a New User and Granting Permissions in MySQL on ServerStadium


  • A ServerStadium VM or dedicated server running MySQL. Explore ServerStadium’s offerings at VM Pricing and Dedicated Servers.
  • Access to the MySQL server as a user with administrative privileges.

Step 1: Access the MySQL Server

  1. Log in to MySQL:

    mysql -u root -p

    Enter the root password when prompted.

Step 2: Create a New User

  1. Create a New User:

    Execute the following command in MySQL, replacing 'newuser' and 'password' with your chosen username and password.

    CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';

    This command creates a new user who can connect to the MySQL server from the localhost.

Step 3: Grant Permissions to the User

  1. Grant Permissions:

    After creating the new user, you need to grant them specific privileges based on their role.

    To grant all privileges to the user on all databases:

    GRANT ALL PRIVILEGES ON <em>.</em> TO 'newuser'@'localhost';

    For specific privileges:

    GRANT SELECT, INSERT ON <code>mydb</code>.* TO 'newuser'@'localhost';

    Replace mydb with the name of your database and adjust the privileges (SELECT, INSERT, etc.) as needed.

  2. Apply the Privileges:

    After granting the privileges, you need to flush the privileges to apply the changes:



Your new MySQL user is now set up with the specified privileges on your ServerStadium server. Managing MySQL users and their permissions is crucial for maintaining the security and integrity of your databases. For more information on server and database management, visit our knowledge base or contact our support team.

Table of Contents