Friday, December 19

Create Mysql User account and Grant permissions to User in Linux command line

                                                                     

Mysql:

MySQL is most commonly used for Web applications and for  embedded  applications  and  has become a popular alternative to proprietary database systems because of its speed  and reliability. MySQL can run on LINUX, Windows and Mac OS.

          By default remote access to the MySQL database server is disabled for security reasons.
However, some time you need to provide remote access to database server from home or a web server.

Step1: First connect mysql root user

        #  mysql -u root -p
           Enter password:
           mysql>

Step2: Create New User in Mysql Command line with password

   mysql> CREATE USER 'mahesh'@'%' IDENTIFIED BY 'password';

Step3: I allow the MySQL user “mahesh” to access all MySQL databases from any remote host.

   mysql> GRANT ALL PRIVILEGES ON * . * TO 'mahesh'@'%';

   mysql> FLUSH PRIVILEGES;
  (Your changes will now be in effect)

Step3.1: If you want to access single database to user "mahesh" from any remote host.

   mysql> GRANT ALL PRIVILEGES ON  dbname.* TO 'mahesh'@'%' WITH GRANT OPTION;
 
   mysql> FLUSH PRIVILEGES;
   (Your changes will now be in effect)

Step4: View a list of Mysql Users

     Viewing a full list of MySQL users, including the host they’re associated with following command.
   

    mysql> select user,host from mysql.user;

Step5: Exit Mysql, using exit command

  mysql> exit

No comments:

Post a Comment

:: Linux - Legends ::