Thursday, August 25, 2016

MySQL installation from scratch

1) Once login to unix system update the yum repositories by issuing following command.
$sudo yum update

2) Find if there are any traces of previously installed mysql on the system
$rpm -qa | grep mysql

3) You can either issue following command to directly install MySQL from exisitng repos.
$sudo yum localinstall mysql-community-common-5.7.24-1.el7.x86_64.rpm 
mysql-community-libs-5.7.24-1.el7.x86_64.rpm mysql-community-client-5.7.24-1.el7.x86_64.rpm 
mysql-community-devel-5.7.24-1.el7.x86_64.rpm mysql-community-server-5.7.24-1.el7.x86_64.rpm

(This will install mysql server along with all its dependencies)
(or)
Alternatively you can download the latest or your required community version of MySQL & update your repository first and then install it.

   $wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
   $sudo rpm -ivh mysql57-community-release-el7-8.noarch.rpm
   $yum update
   $sudo yum install mysql-server 

(This will install mysql server along with all its dependencies)
(Do not proceed with below step if you would like to have custom configurations for MySQL. Update /etc/my.cnf file first & then proceed with below step)
4) Start mysql service    
$sudo systemctl start mysqld

5) Verify if mysqld service is started successfully or not.
$sudo systemctl status mysqld

6) Get the default root password created with installation for mysql 'root' user account.
$sudo grep 'temporary password' /var/log/mysqld.log

7) Connect to mysql instance using temporary root password & update the root password.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'XXyyZZ!';

8) Once mysql is installed you have to secure the mysql access. For more details you can refer to one of my blogs "MySQL Secure Installation" with multiple options.

No comments:

Post a Comment