How to Create a New User and Grant Permissions in MySQL
890

To create a new user and grant permissions in MySQL, you can use the following steps:

  1. Connect to the MySQL server: mysql -u root -p

  2. Create a new user: CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';

  3. Grant the necessary permissions to the user. For example, to grant the user all permissions for the database mydatabase, you can use the following command: GRANT ALL PRIVILEGES ON mydatabase.* TO 'newuser'@'localhost';

  4. If you want to grant the user permissions for all databases, use the following command: GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost';

  5. If you want to grant specific permissions, you can use the GRANT command followed by the specific privileges you want to grant. For example: GRANT SELECT, INSERT, UPDATE ON mydatabase.* TO 'newuser'@'localhost';

  6. If you want to grant the user access from a remote host, you can specify the hostname or IP address in place of localhost.

  7. Flush the privileges to apply the changes: FLUSH PRIVILEGES;

  8. Exit the MySQL prompt: EXIT;

 

If you are looking for consultation, fill the Contact Form below.
The fastest way to change yourself is to hang out with people who are already the way you want to be. Reid Hoffman
Haluk YAMANER - Personal
Contact Form
You must complete Security Verification to submit your form.