How to create users in mysql database?

Member

by gilbert , in category: MySQL , 4 months ago

How to create users in mysql database?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lottie , 4 months ago

@gilbert 

You can create users in MySQL database by following these steps:

  1. Open MySQL Command Line Client or any other MySQL client tool.
  2. Connect to the MySQL server using the command: mysql -u root -p
  3. Enter your root password when prompted.
  4. To create a new user, use the following SQL command: CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; Replace 'username' with the desired username and 'password' with the desired password.
  5. Grant permissions to the user by using the following command: GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost'; This command grants all privileges on all databases to the user. You can modify the permissions according to your requirements.
  6. To apply the changes and refresh the privileges, use the command: FLUSH PRIVILEGES;
  7. Exit the MySQL client by typing: exit


Your new user should now be created in the MySQL database.