# Create a user named user1 with password secret
# Create a database named db1
# Grant the user1 access to the database db1
 

CREATE USER 'user1'@'localhost' IDENTIFIED BY 'secret';     # create user/pswd if using socket 
CREATE USER 'user1'@'%'         IDENTIFIED BY 'secret';     # create user/pswd if using TCP/IP 
                                                            # inserts 2 new rows in user table 

CREATE DATABASE db1;                                        # create a database
                                                            # at O/S, this creates a new folder

GRANT ALL ON  db1.*  TO  'user1'@'localhost';               # grant all privliges, except for GRANT
GRANT ALL ON  db1.*  TO  'user1'@'%';                       # grant all privliges, except for GRANT
                                                            # inserts a new row in db table
 
UPDATE  user                                                # grant additional privliges
   SET  file_priv='Y'                                       # file privilege
 WHERE  user='user1';                                       # to user