Creating New user in Mysql using command line

Creating New user in Mysql using command line:-

To create a new user using command Line follow these steps.

  • First Login to mysql using root.
    mysql -u root -p
  • Create new user
    CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
  • Provide user access
    GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
  • Once you finished with access reload all privileges.

Give Different User Permission

  • ALL PRIVILEGES–  This will give all privileges to user.
  • CREATE– allows users to create new tables or databases.
  • DROP– allows users to delete tables or databases
  • DELETE– allows users to delete rows from tables
  • INSERT– allows users to insert rows into tables
  • SELECT– allows users to use the Select command to read through databases
  • UPDATE– allow users to update table rows
  • GRANT OPTION– allows users to grant or remove other users’ privileges
 GRANT [type of permission] ON [database name].[table name] TO ‘[username]’@'localhost’;

Leave a Reply

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