How To Create a New User and Grant Permissions in MySQL
How to Create a New User
Letβs start by making a new user within the MySQL shell:
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
At this point newuser
has no permissions to do anything with the databases. In fact, even if newuser
tries to login (with the password, password
), they will not be able to reach the MySQL shell.
Grant Permissions
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
Flush
FLUSH PRIVILEGES
Create Super User (root like)
Create the user:
CREATE USER 'kingkong'@'localhost' IDENTIFIED BY 'joe rilla in da house'
Grant superuser rights:
GRANT ALL PRIVILEGES ON *.* TO 'kingkong'@'localhost' WITH GRANT OPTION;