How to install mysql in linux with practical

 

Summary

In the previous tutorial we have learned about the introductionof mysql and advantages of mysql . In this article we will learn how to install mysql in linux operating system like centos ,oracle,redhat and ubuntu.

Prerequisite

To install mysql in linux system first we need to have a system with linux operating system. Now you can disable selinux as per your requirement and then configure yum repository to install mysql package from centralized yum repository. By default  mysql runs on port no 3306. You can configure firewall on linux system as per your requirement.

Install mysql in linux

Now we have configured yum repository. First we need to verify that whether mysql server package is installed or not on the server using the below command.

#rpm –qa mysql*

If package is installed on the server you will get the output and you have nothing to do. If this package is not installed the server you need to install mysql package using you repository. Upto linux version 6.x mysql package is available in the yum repository . After 6.x or 7.x onward we can use mysql repository to install mysql server package.

To search mysql package it is available or not and which version will be available we can execute the below command.

#yum provides mysql*

Note:  Mysql* means we can get all mysql related package from the yum repository.

 To install mysql server in linux system(rhel,centos,oracle)  we need to execute the below command.

#yum install mysql-server

How to install mysql in linux
How to install mysql in linux


Start mysql service in linux

After installation of mysql server we need to start the service and check the service status  using the below commands.

[root@mysqldailytasks ~]# service mysqld start

Starting mysqld:                                           [  OK  ]

[root@mysqldailytasks ~]# service mysqld status

mysqld (pid  1547) is running...


To enable mysqld service at the startup mode i.e After reboot the physical server mysqld service will be automatically using the below command.

 

#chkconfig mysqld on

 

How to secure and set mysql root password

After completion above all steps we need to secure mysql root password using the below command.

 [root@mysqldailytasks ~]# mysql_secure_installation 


NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

 

 

In order to log into MySQL to secure it, we'll need the current

password for the root user.  If you've just installed MySQL, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

 

Enter current password for root (enter for none):

OK, successfully used password, moving on...

 

Setting the root password ensures that nobody can log into the MySQL

root user without the proper authorisation.

 

You already have a root password set, so you can safely answer 'n'.

 

Change the root password? [Y/n] y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

 ... Success!

 

 

By default, a MySQL installation has an anonymous user, allowing anyone

to log into MySQL without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

 

Remove anonymous users? [Y/n] n

 ... skipping.

 

Normally, root should only be allowed to connect from 'localhost'.  This

ensures that someone cannot guess at the root password from the network.

 

Disallow root login remotely? [Y/n] n

 ... skipping.

 

By default, MySQL comes with a database named 'test' that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.

 

Remove test database and access to it? [Y/n] n

 ... skipping.

 

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

 

Reload privilege tables now? [Y/n] y

 ... Success!

 

Cleaning up...

 

 

 

All done!  If you've completed all of the above steps, your MySQL

installation should now be secure.

 

Thanks for using MySQL!



How to connect mysql server from linux terminal

To connect mysql server from linux shell we need to execute the below command.

Mysql –u root –p

Enter password:


Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 8

Server version: 5.1.71 Source distribution

 

Copyright (c) 2000, 2013, 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> 


Check mysql version

To check mysql version we can execute the below query in mysql promt.

mysql> select version();

+-----------+

| version() |

+-----------+

| 5.1.71    |

+-----------+

1 row in set (0.00 sec)

  

Conclusion

 In this article we have learned  how to install mysql in linux operating system like centos ,oracle,redhat and ubuntu,how to start the mysql service,how to secure root password for mysql,how to connect mysql from linux shell and finally how to check version of mysql server.

Introduction of Mysql and its features

 

Summary

In this tutorial we will learn aboutintroduction of mysql. Also we will learn about what is database,type of database, what is mysql, advantages or we can sayfeatures of mysql.


What is database

Database is collection of datas which will stored in the organized manners in database and it will be easily accessed by database admin.

Lets take an example to explain database. Suppose in a school there will be many students and each student has name , age ,roll no so school authority collects each and every record from every student and store all datas into a database. Therefore we can access each and every students data in organized manner and if required we can view ,modify and delete the particular data from the database.


Type of database

Now we have learned what is database. Now we will learn type of database. There is two types of database one is relational database and other is no sql database.
Relational database will stored the data in structure manner and it will be easy to understand and easy to access. Relational database usesSQL (structured query languages). Example of the  relational  is oracle,mysql,postgresql.

Introduction of Mysql
Introduction of MySql


No SQL database will not stored data in structured manner . It will stored data in document format. It will no used SQL language.It can not be maintain any relation between table like relational database. Example of noSQL database is mongodb.
 

What is  Mysql

MySQL is free and open source most popular and well known relational database management system all over the world. It is used for various web based software application.Mysql can be integrated with php,java and many others programming languages.Mysql has cross platform feature means we can use / install mysql server in windows,linux and mac operating system.
 

Advantage of Mysql

  1. Mysql is a free and open source database . so that we can download mysql free.
  2.  Mysql is relational database management system  because in one mysql database there will be many tables and each table has a relation with the other table.
  3.  Mysql supports cross platform because we can use mysql in  the various operating system like Windows , linux and mac operating system.
  4.  Mysql stores data in the structured manner using sql language.
  5.  Mysql is very fast, reliable and scalable database . mysql can handle small site as well as large sites due to its scalability.
  6.  Mysql supports many programming languages like php,java and so on.
  7.  Mysql is very secure database.
  8.  Mysql database is used by many big companies like google,facebook etc.
  9.  Mysql supports roll back and commit operation.
  10.  Moreover mysql is easy to learn.

 

Conclusion

In this tutorial we have learned about introduction of mysql. Also we have learned about what is database,type of database, what is mysql, advantage or we can sayfeatures of mysql.

In next article we will learn how to install mysql in linux.