Monday 5 November 2012

How to create user and set password in mysql


First login root user in mysql

        [root@sysadmin ~] # mysql -u root -p
 

Create the user

               mysql > create user test_user@localhost;

Set password for 'test_user'

          mysql > SET PASSWORD FOR 'test_user'@'localhost'  =  PASSWORD('test@1234');


Check test_user can able to login or not

      [root@sysadmin ~]# mysql  -u  test_user  -p
      Enter password:
 

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.1.67-log Source distribution

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit


 Successfully created user and set password. 


Check user list on mysql

                mysql> SELECT User FROM mysql.user; 


How to remove user in mysql

           mysql>  drop   user   'test_user'@'localhost';


No comments:

Post a Comment