Thursday, December 8, 2011

Adding User Accounts in MYSQL

 

CREATE USER 'sam'@'localhost' IDENTIFIED BY 'some-password';

 

GRANT ALL PRIVILEGES ON *.* TO 'sam'@'localhost' WITH GRANT OPTION;

 

FLUSH PRIVILEGES;  (telling the server to reload the grant tables using flush command)

 

 

The accounts created by these statements have the following properties:

 

Two of the accounts have a user name of sam and a password of some_pass. Both accounts are superuser accounts with full privileges to do anything. The 'sam'@'localhost' account can be used only when connecting from the local host. The 'sam'@'%' account uses the '%' wildcard for the host part, so it can be used to connect from any host.

1 comment:

  1. To Update User Password

    > UPDATE user SET Password=PASSWORD('any-pass') WHERE User='admin' AND Host='ip';

    > FLUSH PRIVILEGES;

    ReplyDelete