Creating and Updating MySQL User
Creating a New MySQL 'root' User and Granting Privileges
To create a new MySQL 'root' user with the password 'root@123' and grant privileges:
sudo mysql -u root -p
CREATE USER 'root'@'localhost' IDENTIFIED BY 'root@123';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Updating Password of Existing MySQL 'root' User
To update the password for an existing MySQL 'root' user:
sudo mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root@123';
FLUSH PRIVILEGES;
Example Session
An example session demonstrating the commands:
sudo mysql -u root -p
CREATE USER 'root'@'localhost' IDENTIFIED BY 'root@123';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root@123';
FLUSH PRIVILEGES;
For more detailed instructions, consult the MySQL documentation.
0 Comments