Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

โ€œInvest in yourself โ€” your confidence is always worth it.โ€

Explore Cosmetic Hospitals

Start your journey today โ€” compare options in one place.

MySql Tutorials: How to grant user access to Database?


To grant a user access to a specific database in MySQL, you can use the following GRANT statement:


GRANT privileges ON database_name.* TO 'user_name'@'host' [IDENTIFIED BY 'password'];
Code language: JavaScript (javascript)

Where:

  • privileges: the privileges you want to grant to the user. This can be a combination of SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, and other privileges.
  • database_name: the name of the database you want to grant the user access to.
  • user_name: the name of the user you want to grant the privileges to.
  • host: the host from which the user is connecting. This can be specified as a wildcard (e.g., '%') to allow access from any host.
  • password: the password for the user (optional).

For example, to grant a user with the username 'john' and password 'password' the ability to select data from the database 'mydatabase', the following command can be used:


GRANT SELECT ON mydatabase.* TO 'john'@'%' IDENTIFIED BY 'password';
Code language: JavaScript (javascript)

After executing the GRANT statement, you need to run the FLUSH PRIVILEGES command to reload the privileges and apply the changes:


FLUSH PRIVILEGES;

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals

Similar Posts

Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments