MySQL on OS X

Seems like everytime I revisit mysql I'm confused about login & user creation, so here it is again:

log in using:

mysql -u USERNAME

create user using:

use mysql;
insert into user(host,user,password,select_priv) values
('localhost','USERNAME',password('PASSWORD'),'Y');

grant privileges to user:

grant all privileges on *.* to 'USERNAME'@'localhost' with grant option;

make sure to flush privileges to enable new accounts:

flush privileges;

to log in:

mysql --user=USERNAME --password=PASSWORD (optional: db name)

No comments: