How to create admin or superuser in mysql 8?

Member

by darion , in category: MySQL , a year ago

How to create admin or superuser in mysql 8?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by jerad , a year ago

@darion 

In MySQL 8, you can create an admin or superuser by following these steps:

  1. Connect to your MySQL server as a user with administrative privileges. This user should already exist and have the necessary privileges to create new users.
  2. Open a MySQL command line or terminal.
  3. Run the following command to create a new MySQL user: CREATE USER 'admin'@'localhost' IDENTIFIED BY 'password'; Replace 'admin' with the desired username and 'password' with a strong password.
  4. Grant administrative privileges to the user by running the following command: GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION; This grants all privileges on all databases and tables to the 'admin' user.
  5. If you want to allow remote connections for the user, replace 'localhost' with the IP or hostname of the remote machine or use '%' to allow connections from any host. For example: CREATE USER 'admin'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;
  6. Finally, flush the privileges to ensure the changes take effect immediately: FLUSH PRIVILEGES;


Now you have created an admin or superuser in MySQL 8.