• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • Life always offers you a second chance ... Its called tomorrow !!!

    Monday, May 20, 2013

    How to create a MySQL database USER and ASSIGN PRIVILEGE

    Creating a database user and system user are two different things. In this post I will be telling you the steps required to create a MySQL database user and assigning privilege.

    For installing and creating database please follow this link

    Login to your database
    # mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor. 
    Commands end with ; or \g. 
    Your MySQL connection id is 1112 Server version: 5.0.77 Source distribution 
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
    
    mysql> create user deepak@'localhost' identified by 'my_password'; 
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> GRANT ALL PRIVILEGES on test.* to deepak@'%'; 
    Query OK, 0 rows affected (0.00 sec)
    
    NOTE: The host definition of '%' or '' (null) refers to any host.
    
    mysql> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.00 sec)

    Now we will verify if the user deepak has got all the privilege assigned to him. Let us try to insert some values in the tables for the database he has been given permission.
    # mysql -u deepak -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 1111
    Server version: 5.0.77 Source distribution
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
    
    mysql> show databases;
    +--------------------+
    | Database           | 
    +--------------------+
    | information_schema |
    | mycomp             |
    +--------------------+
    2 rows in set (0.00 sec)
    mysql> use mycomp;
    Database changed
    mysql> INSERT INTO employee VALUES ('3','Anita Chaudhary','22');
    Query OK, 1 row affected (0.00 sec)
    mysql> SELECT * from employee;
    +----------+-----------------+------+
    | SerialNo |          Name   |  Age |
    +----------+-----------------+------+
    | 1        | Deepak Prasad   |   23 |
    | 2        |  Amit Dubey     |   24 |
    | 3        | Anita Chaudhary |   22 |
    +----------+-----------------+------+
    3 rows in set (0.00 sec)


    Follow the below links for more tutorials:

    Configure Red Hat Cluster using VMware, Quorum Disk, GFS2, Openfiler
    Tutorial for Monitoring Tools SAR and KSAR with examples in Linux
    How to configure Samba 4 Secondary Domain Controller
    How to secure Apache web server in Linux using password (.htaccess)
    How to register Red Hat Linux with RHN (Red Hat Network )
    Red hat Enterprise Linux 5.5 Installation Guide (Screenshots)
    15 tips to enhance security of your Linux machine
    Why is Linux more secure than windows and any other OS
    What is the difference between "su" and "su -" in Linux?
    What is kernel-PAE in Linux?
    What is swappiness and how do we change its value?
    How to log iptables messages in different log file
    What are the s and k scripts in the etc rcx.d directories
    How to check all the currently running services in Linux
    How to auto start service after reboot in Linux
    What is virtual memory, paging and swap space?

    0 comments:

    Post a Comment