How do I add a user to MySQL?

By Alvin J. Alexander, devdaily.com

See these two URLs for info on adding and removing users:



Here's an example of what I did recently to actually create a new database and user. Of course the database name, username, and password have been changed:


mysql -u root -p
(here I enter 'my_root_password' to get through the mysql prompt)

create database my_database;

GRANT ALL PRIVILEGES 
ON my_database.* 
TO 'my_user'@'localhost'
IDENTIFIED BY 'my_password' 
WITH GRANT OPTION;

All of this is pretty much straight from the manual, but hopefully one more example helps.


devdaily logo