Wednesday, February 10, 2010

mySQL commands - User Account Management

A MySQL account is defined in terms of a user name and the client host or hosts from which the user can connect to the server.
MySQL user names can be up to 16 characters long.

shell>mysql --u monty --pguess db_name
shell>mysql --user=monty --password=guess dbname

Create a db and user, assign privilges to the user for db access
mysql>create database wordpress;

mysql>create user 'wpuser'@'localhost' IDENTIFIED BY 'P@$$w0rd';

mysql>grant usage on *.* to wpuser@localhost;
(allow user wpuser to connect to the server from localhost using the password P@$$w0rd)

mysql>grant all privileges on wordpress.* to wpuser@localhost;
(grant all privileges on the wordpress database to user wpuser)

No comments: