Monday 25 March 2013

Installing MySQL from RPM Packages

Step By Step Installation of MySQL in Linux

For the installation of MySQL in any Linux Server requires the following important files :
A) Files Required to Install MySQL
1) MySQL-server-*.rpm
2) MySQL-client-*.rpm
3) MySQL-devel-*.rpm
4) MySQL-shared-*.rpm
5) MySQL-shared-compat-*.rpm

1) MySQL-server-*.rpm :: You need to install when you have to connect multiple clients through this MySQL Server on network.
2) MySQL-client-*.rpm :: You probably require this program to connect with the server machine.
3) MySQL-devel-*.rpm  :: This includes libararies and files require to connect with other cliemt such as Perl.
4) MySQL-shared-*.rpm :: This package includes the shared libararies libmysqlclient.so*, only one package is need to install in both shared and shared-compat version.
5) MySQL-shared-compat-*.rpm :: This package includes all the libararies for older releases to the current version.

B) Remove the existing Default MySQL
# rpm -qa | grep mysql
mysql-5.0.22-2.1.0.2

# rpm -e mysql-5.0.22-2.1.0.2

C) Install the MySQL Packages
As a standard configuration following packages are sufficient to run MySQL :
rpm -ivh MySQL-client-*.rpm
rpm -ivh MySQL-server-*.rpm


In case you require Libararies to install :
rpm -ivh MySQL-devel-*.rpm

In case you require shared libararies for the application support / old version compatability :
rpm -ivh MySQL-shared-*.rpm
OR
rpm -ivh MySQL-shared-compat-*.rpm


And start the mysql server
/sbin/service mysql START

D) Setup secure MySQL Installation

First, You need to set a password for the ROOT user after restarting the MySQL
/usr/bin/mysqladmin -u root -p '<new-password>'
Note : For the New installation for MySQL 5.6.x. The root password stores in a default file in /root/ directory in .mysql_secure file.
Otherwise, you can run MYSQL_SECURE_INSTALLATION, which updates the following task :
* Change the Root Password
* Remove the Anonymous user
* Restrict Remote login from Remote machines
* Removes the default test database

/usr/bin/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] Y
... Success!
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] Y
... Success!
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] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
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!


E) Login to the MYSQL
[Local-host]# mysql -u root -p<password>
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.5.10-rc-community MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;