Tuesday 28 April 2015

How to Install mysql server 5.6 on Ubuntu 14.04 LTS



1)
 Install MYSQL server 5.6.

Install MySql Server 5.6 using "apt-get" command.

anusree@anusree-VirtualBox:~$ sudo apt-get update
anusree@anusree-VirtualBox:~$ sudo apt-get install mysql-server-5.6

at the time of mysql installation you have to set password for the mysql roor user screen shot given bellow:



It will again ask mysql root password for confirmation screen shot given bellow:


2)
Login into MYSQL server.

After mysql server installation get finishes , it start the mysql service automatically. Hence, you can login now in MySQL Server with user root.
Login into MYSQL using:

    anusree@anusree-VirtualBox:~$ mysql -u root -p


3)
To Start MYSQL service:

    anusree@anusree-VirtualBox:~$ sudo service mysql start


4)
To Stop MYSQL service:

    anusree@anusree-VirtualBox:~$ sudo service mysql stop


 5)
 To Restart MYSQL service:

    anusree@anusree-VirtualBox:~$ sudo service mysql restart

 
 6)
Status of MYSQL after start:

    anusree@anusree-VirtualBox:~$ sudo service mysql status



 7)
 Status of MYSQL after stop:

     anusree@anusree-VirtualBox:~$ sudo service mysql status


8)
If you want to add new user, the command is given bellow:

    mysql> CREATE USER 'test'@'localhost' IDENTIFIED BY 'test123';
  
    Here, test ---> user name and, test123 is password for user "test".



9)
View the full list of mysql users, the command is given bellow:

   mysql> SELECT User,Host FROM mysql.user;




10)
How to delete a user in mysql the command is given bellow:

   mysql> DROP USER 'test'@'localhost';

and after deleting the user view the full list of mysql users



11)
How to grand different user permission:

  •  ALL PRIVILEGES- as we saw previously, this would allow a MySQL user all access to a designated database (or if no database is selected, across the system)
  •   CREATE- allows them to create new tables or databases
  •   DROP     -    allows them to them to delete tables or databases
  •   DELETE -    allows them to delete rows from tables
  •   INSERT -    allows them to insert rows into tables
  •   SELECT -    allows them to use the Select command to read through databases
  •   UPDATE -   allow them to update table rows
  •   GRANT OPTION- allows them to grant or remove other users' privileges


The command for grand permission to the user is :

GRANT [type of permission] ON [database name].[table name] TO ‘[username]’@'localhost’;



Suppose we have two user named "test" and "sample", and i am going to give SELECT permission to the user "test" and INSERT permission to the user "sample".

1)
Here we have two user "test" and "sample".



2)
Next i am going to give SELECT permission to the user "test".



3)
Next i am going to give INSERT permission to the user "sample".








Now the user "test" has only SELECT permission and the user "sample" have only INSERT permssion.

4)
Now i am going to check the permission of the user test. For that first i have to login as user "test".





The above picture shows that the user "test" have only SELECT permission.
When the user "test" try to insert a data to the table student it will cause error


5)
Now i am going to check the permission of the user sample. For that first i have to login as user "sample".




The above picture shows that the user "sample" have only INSERT permission.
When the user "sample" try to select a data to the table student it will cause error also try to delete a data from the table stdent will causes error.


No comments:

Post a Comment