You can create a new user and grant all privileges on a specific database in MySQL using the following steps:

  1. Log in to your MySQL server as a user with administrative privileges using the following command
    sudo mysql -u root -p This will prompt you to enter the MySQL root password.
  2. Create a new user by running the following SQL command:
    CREATE USER 'shahid'@'localhost' IDENTIFIED BY 'password'; Replace new_user with the desired username and password with the desired password.
  3. Grant all privileges on the shahid database to the new user by running the following SQL command:
    GRANT ALL PRIVILEGES ON shahid.* TO 'new_user'@'localhost';
    This will grant all privileges on the shahid database to the user new_user from the localhost host.
  4. Reload the privileges by running the following SQL command:

    FLUSH PRIVILEGES; This will reload the privileges and make the changes take effect immediately.

If any syntax error then run! these commands

CREATE USER ‘shahid’@’localhost’ IDENTIFIED BY ‘shahidpassword321!!!@#’;

GRANT ALL PRIVILEGES ON *.* TO ‘shahid’@’localhost’;

FLUSH PRIVILEGES;

Categorized in:

Uncategorized,

Last Update: March 29, 2023