Create a user
For local mysql access
CREATE USER 'USERNAME-HERE'@'localhost' IDENTIFIED BY 'PASSWORD_HERE'; GRANT ALL PRIVILEGES ON DB_NAME_HERE.* TO 'USERNAME-HERE'@'localhost'; FLUSH PRIVILEGES;
To allow remote access, run
CREATE USER 'USERNAME-HERE'@'%' IDENTIFIED BY 'PASSWORD_HERE'; GRANT ALL PRIVILEGES ON DB_NAME_HERE.* TO 'USERNAME-HERE'@'%'; FLUSH PRIVILEGES;
To allow a user to create another user
GRANT GRANT OPTION ON *.* TO 'USERNAME-HERE'@'localhost';
Now this user will be able to create new users.
Create a user with root privilages
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'MYSQL_PASSWORD' WITH GRANT OPTION; GRANT PROXY ON ''@'' TO 'admin'@'localhost' WITH GRANT OPTION;
For MySQL 8
CREATE USER 'admin'@'%' IDENTIFIED BY 'AEs308SuEtT0Hs'; GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;
Leave a Reply