Install Mysql in Linux step by step

Installing MySQL in linux is not as easy as in windows, so here are some of the steps you can take to achieve it.

Download the latest (or preferred) version of MySQL to a preferred location from here.

So, for this example im going to download Mysql Server to my Downloads directory.

$ cd /home/tutorial/Downloads
$ wget http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.0-m2-linux-x86_64-icc-glibc23.tar.gz

We have MySQL now. so, lets get started.

We will first add a group and a user named MySQL to own and run the MySQL process. (for this you need to login as root user)

$ su –
enter root password:
# groupadd mysql
# useradd -r -g mysql mysql

Now, since that is done we move on to the installation. We move to “/usr/local/” and extract the tar to that location.

# cd /usr/local
# tar zxvf /home/tutorial/Downloads/mysql-5.5.0-m2-linux-x86_64-icc-glibc23.tar.gz

create a soft link for the installation and go to through that link. (for easy access)

# ln -s mysql-5.5.0-m2-linux-x86_64-icc-glibc23 mysql
# cd mysql

We will give permissions over the MySQL files to mysql user to avoid any security risks of running MySQL as root.

# chown -R mysql .
# chgrp -R mysql .

Then, we will install the MySQL initial db and grant access to root and grant access to the data directory to mysql user.

# scripts/mysql_install_db –user=mysql
# chown -R root .
# chown -R mysql data

Well that’s it! we have the basic MySQL server installed. To start the server;

# bin/mysqld_safe –user=mysql &

Now, Check if the installation is complete.
logout as super user or open a new terminal and give the following command. The password should be blank since we have not set it.

$ mysql -uroot -p

You will be shown the MySQL version plus other details with the mysql prompt.

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.33-log MySQL Community Server (GPL)

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>

So, there you have it.


Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.