You can create a new user and grant all privileges on a specific database in MySQL using the following steps:
- Log in to your MySQL server as a user with administrative privileges using the following command
sudo mysql -u root -pThis will prompt you to enter the MySQL root password.
- Create a new user by running the following SQL command:
CREATE USER 'shahid'@'localhost' IDENTIFIED BY 'password';Replace
new_userwith the desired username and
passwordwith the desired password.
- Grant all privileges on the
shahiddatabase 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
shahiddatabase to the user
- 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’;