How to Install MySQL 5.5 on CentOS 6.3/Redhat EL6/Fedora

Standard

First head over here and download MySQL 5.5.30 [Can be any minor version, I have this as this is latest when I was writing this post] rpm’s under Oracle & Redhat Linux 6 platform section of rpm’s.You want to download these rpm’s to your CentOS 6 server [As we will install 64bit version on MySQL 5.5] :

  1. Red Hat/Oracle Enterprise Linux ver. 6 (x86, 64-bit), RPM Package – MySQL Server : MySQL-server-5.5.30-1.el6.x86_64.rpm
  2. Red Hat/Oracle Enterprise Linux ver. 6 (x86, 64-bit), RPM Package – Shared components : MySQL-shared-5.5.30-1.el6.x86_64.rpm
  3. Red Hat/Oracle Enterprise Linux ver. 6 (x86, 64-bit), RPM Package – Client Utilities : MySQL-client-5.5.30-1.el6.x86_64.rpm

Alternatively to directly download on command line [Note : Make sure that you have wget utility installed in your CentOS, if not install it: ]

yum install wget

 

Download the rpm’s command line with the following wget commands.

wget http://www.mysql.com/get/Downloads/MySQL-5.5/MySQL-server-5.5.30-1.el6.x86_64.rpm/from/http://cdn.mysql.com/

wget http://www.mysql.com/get/Downloads/MySQL-5.5/MySQL-client-5.5.30-1.el6.x86_64.rpm/from/http://cdn.mysql.com/

wget http://www.mysql.com/get/Downloads/MySQL-5.5/MySQL-shared-5.5.30-1.el6.x86_64.rpm/from/http://cdn.mysql.com/

 

mysql 5.5 download

Now start installing rpm’s onto your server:

Make sure that Perl is installed on your server before you install MySQL, if not MySQL server rpm will complain that it cannot be installed. So its kind of pre-requisite.

mysql 5.5 perl dependency

To Install perl run :

yum install perl

mysql 5.5 perl installed

Install MySQL 5.5 rpms now :

Start with shared libraries first and then work towards installing server and client utilities at the very end.

rpm -ivh MySQL-shared-5.5.30-1.el6.x86_64.rpm
rpm -ivh MySQL-client-5.5.30-1.el6.x86_64.rpm
rpm -ivh MySQL-server-5.5.30-1.el6.x86_64.rpm

Image 007

MySQL Server Installation log:

Preparing… ########################################### [100%]
1:MySQL-shared ########################################### [100%]
[root@opensourcedbms ~]# rpm -ivh MySQL-server-5.5.30-1.el6.x86_64.rpm
Preparing… ########################################### [100%]
1:MySQL-server ########################################### [100%]

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password ‘new-password’
/usr/bin/mysqladmin -u root -h opensourcedbms password ‘new-password’

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

Please report any problems with the /usr/bin/mysqlbug script!

Its all done, lets set some passwords, create user and grant access to outside clients for accessing the database. To do that we need to start our newly installed database server.

service mysql start

Image 008

Now before logging into database server using MySQL client utility, we need to set the database root user password. To set the root user password run the following command as showed below. Replace this password to what ever you desire. Also there are other root users in MySQL if you are familiar with its users table [root@127.0.0.1 ; root@::1, root@hostname], once you login with superuser you can update all of them later.

/usr/bin/mysqladmin -u root password 'opensourcedbms'

Image 009

Now lets login into the database server to create a super user for granting outside world access to the databases. Login with root and when prompted for password please provide the password that you have set for root user in the earlier step.

mysql -uroot -p

Image 010

create a super user to access database server from outside server. Its not a good practice to grant root user access to outside world.

CREATE USER 'superadmin'@'%' IDENTIFIED BY 'opensourcedbmsadmin';
GRANT ALL ON *.* TO 'superadmin'@'%' WITH GRANT OPTION;

Image 011

Now we can use this newly created user to access this database server from outside world. Before you can do that, make sure that your server firewall rules are updated for granting this server to respond at port 3306 for outside world. First get out of the mysql command line client [\q] and to add a new firewall rule to your CentOS database server firewall rules and to do that edit

vi /etc/sysconfig/iptables

file and add the following line:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

Image 012

Save and exit out of the file and restart iptables for the new rule to take effect. To restart iptables, simply run the following command :

service iptables restart

Image 013

Last but not least make sure that this new MySQL server is enabled to auto start when server restarts.

chkconfig mysql --level 2345 on

Now you are ready to connect to this database server from any host in your network. Simply open a database client [MySQL Workbench / Navicat / SQLYog are few clients that you can use to access it from GUI side of things] that you installed and provide the new super user/password that you created and the host-name/ip of this server and there you will be in your new database server.

mysql 5.5 sqlyog

Image 015

If you are running this server in a virtual box environment, make sure that you do port forwarding (NAT Only) to pass through 3306 database port to guest VM which can be done by going to settings of your VM > Network > Advanced > Port forwarding. This is more specific to Oracle Virtual Box.

Facebooktwittergoogle_plusredditpinterestlinkedinmail

About Prashanth Goriparthi

Sr. Database Administrator / Architect

Leave a Reply

* Captcha [Please fill/solve below] : * Time limit is exhausted. Please reload the CAPTCHA.