Wednesday, October 24, 2018

MariaDB & phpMyAdmin on CentOS 7

MariaDB & phpMyAdmin on CentOS 7

Video URL : https://youtu.be/SM_Efy40zso?list=PLEiDY15kH-ieq5E63exIhVkd-Ldie3PTy
Video Title : How to Install Mariadb / Mysql in CentOS 7
Youtube upload URL : https://www.youtube.com/watch?v=SM_Efy40zso&feature=youtu.be&list=PLEiDY15kH-ieq5E63exIhVkd-Ldie3PTy
Youtube upload Title : MariaDB setup on CentOS7-by-NCD0318H021
Task 1 : Install and configure MariaDB in CentOS7
Solution :
Step1 :
#Login into Guest VM on centos7
#Add MariaDB Yum Repository as MariaDB.repo under /etc/yum.repo.d
#Add below content to the MariaDB.repo
 vi  /etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
SAVE and CLOSE the file

Step2 :
#install MariaDB as below#
yum install MariaDB-server MariaDB-client -y
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo systemctl status mariadb
#Start, enable and check the status of MariaDB by below commands#

Step 3 :#Now setup the user secure password by the following command
sudo mysql_secure_installation
root MariaDB password set during installation:
Enter current password for root (enter for none):
Then, assuming you set a strong root password, go ahead and enter n at the following prompt:
Change the root password? [Y/n] n
Remove anonymous users, Y:
Remove anonymous users? [Y/n] Y
Disallow root logins remotely, Y:
Disallow root login remotely? [Y/n] Y
Remove test database and access to it, Y:
Remove test database and access to it? [Y/n] Y
And reload privilege tables, Y:
Reload privilege tables now? [Y/n] Y

Step 4 :##Login  into the MariaDB by the below command##
mysql -u root -p

##Now we are inside the MariaDB
#Give the below command to see Data bases available##

Step 5 : 
##See more information about mariadb by using below commands
show database;
use mysql;
show tables;
describe mysql.user;
##Describe command will list the database tables


Task 2 : Create a New MariaDB User , Database and Datatable
Solution : 

Step 1 :
###create a database by the below command ###
create database Database1;

Step 2 :
##create a user
create user 'ncodeitadm'@192.168.11.192 identified by 'password';

Step 3 :
##Give permissions to user on Database
grant all on Database.* to 'ncodeitadm' identified by 'password';
exit

Step 4 :
##Creation of a Database Table
##Login to mariaDB user
mysql -u root -p
## To connect the above user to Database use below command ##
use Database1

##create Sample Database table with the name  SampleTB##
##This creates a table with a customer ID field of the type INT for integer (auto-incremented for new records, used as the primary key), as well as two fields for storing the  SampleTB name:
create table Sample (customer_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, first_name TEXT, last_name TEXT);

Step 5
##To view newly created tables use below command##
show tables;
exit





Video URL : https://youtu.be/8O5HCmI3Lyo?list=PLxlXdZ1Dia3o91pVS0HXdSfcPkicVdwI9
Video Title : How to install PhpMyAdmin on CentOS 6
Youtube upload URL : https://youtu.be/Zd7g3MQlPng?list=PLEiDY15kH-ieq5E63exIhVkd-Ldie3PTy

Youtube upload Title : MariaDB setup on CentOS7-by-NCD0318H021
Task 3 : Install And setup PHPMyAdmin on CentOS 7
Solution :
Prerequisites
 :
VM setup for CentOS7
Must have LAMP stack means Linux, Apache, MariaDB/Mysql , and PHP
Step1 :
sudo yum install epel-release -y

Step2 :
sudo yum install httpd php -y

Step3 :
sudo systemctl start httpd.service
sudo systemctl enable httpd.service
##Make sure php-fpm module is  available or not ##
##install module php-fpm
sudo yum install php-fpm
##Test PHP Processing on your Web Server by creating a file info.php
sudo vi /var/www/html/info.php
<?php phpinfo(); ?>
SAVE and CLOSE file
systemctl stop firewalld
systemctl disable firewalld

##access in browser
http://ip/info.php
sudo rm /var/www/html/info.php                    ##Its not necessary

Step4 :
##install phpMyAdmin
sudo yum install phpmyadmin

sudo vi /etc/httpd/conf.d/phpMyAdmin.conf                        ##Add the below content  ##
<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8<IfModule mod_authz_core.c>
# Apache 2.4
#<RequireAny>
# Require ip 192.168.11.225
# Require ip ::1
#</RequireAny>
Order Deny,Allow
Allow from all
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Allow from All
</IfModule>
</Directory><Directory /usr/share/phpMyAdmin/setup/>
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 192.168.11.225
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 192.168.11.225
Allow from ::1
</IfModule>
</Directory>
Save and Close file
sudo vi etc/httpd/conf/httpd.conf                              ##Add below content##
<Directory /phpmyadmin >
#order deny,allow
#Allow from all
AllowOverride all
Require all granted
Allow from 192.168.11.225
</Directory><Directory /usr/share/phpmyadmin >
#order deny,allow
#Allow from all
AllowOverride all
Require all granted
Allow from 192.168.11.225
</Directory>
Save and Close file
sudo systemctl restart httpd.service

Step 5 :
##Now open browser
http://<IP>/phpMyAdmin
Now login with MariaDB user and password details.

No comments:

Post a Comment