Here we will look at how to View Create and Delete MySQL Users.
Before you can do any of these tasks, you need to login with an admin user:
mysql -u root -p --- (the 'root' part assumes root is your mysql username) mysql -u root -pPassword (no space between -p and your password)
Once logged in you can do the following:
SELECT user, host FROM mysql.user;
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'; Once created, the user requires permissions GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost'; If you want to be able to access the server from anywhere, replace localhost with % GRANT ALL PRIVILEGES ON * . * TO 'admin'@'%';
GRANT ALL PRIVILEGES ON mydb.* TO 'username'@'%' IDENTIFIED BY 'password';
DROP USER 'jeffrey'@'localhost';