Saturday, 16 January 2016

MySQL Server 5.7 Installation and Basic operations




1) Configure local yum or Registered yum repository

2) Download MySQL Server Repository rpm from below link:


https://dev.mysql.com/downloads/file/?id=459921

3) Install rpm

[root@linuxcnf ~]# rpm -ivh mysql57-community-release-el7-7.noarch.rpm

4)install MySQL Server by yum Repository

[root@linuxcnf ~]# yum install mysql-server

5) start service

[root@linuxcnf ~]# service mysqld start
[root@linuxcnf ~]# chkconfig mysqld on

6) MySQL Server security

[root@linuxcnf ~]# mysql_secure_installation  

//follow the instruction as per requirement

7) Change database directory

 a)create new directory for database


[root@linuxcnf ~]# mkdir /dbdata
[root@linuxcnf ~]# chwon -R mysql:mysql /dbdata

 b)chang datadir path datadir = /dbdata in /etc/my.cnf file and restart Service
 datadir = /dbdata

8) Local and Remote Login   //To remote login comment #bind = 127.0.0.1 in /etc/my.cnf file and restart Service

[root@linuxcnf ~]# mysql -u username -ppassword  //Local Login
[root@linuxcnf ~]# mysql -h hostname/ipaddress -d databasename -u username -ppassword

9) User creations

>create user 'username'@'host' identify by 'password';  //user create
>grand all privileges on databasename.* to 'username'@'hostname' identify by 'password';  //user permissions
>FLUSH PRIVILEGES;

10) create Database 

>create database databasename; //create database
>use database databasename; //To use database

11)Drop or delete database

>drop database databasename;

12)Backup and Restore database

 a)Backup

 #mysqldump -u root -p databasename > db_backup.sql //To take backup  of a perticuller database
 #mysqldump -u root -p --all-databases >alldb_backup.sql //To take backup of all databases

 b)Restore

 #create database databasename  //Create an appropriately named database on the target machine
 #mysql -u root -p databasename < db_backup.sql  //Load the file/dump using mysql command.

No comments:

Post a Comment