0% found this document useful (0 votes)
23 views10 pages

4-Maria DBMS

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views10 pages

4-Maria DBMS

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

MariaDB:

Database types:
-SQL DB (DBMS) composed of TABLE (ROWS and COLUMN). In tables , a
row represents a records, In a record, a column represents an attribute of that
record, Not Scalable (fixed size for field), MYSQL, MariaDB and PostgreSQL.
-NO SQL do not depends on tables (ELK Stack) log management solution, Mongo
DB.
-MYSQL is Sun micro systems
-MYSQL in RHEL6, enabled Clustering, can have web interface for easy
management, can be installed in windows
-Mariadb is opensource developed by developers and compatible with MYSQL
and works with RHEL7.

MariaDB Database Installation package:


[root@srv1 ~]# dnf install mariadb-server mariadbmariadb-libs

We have to start and Enable the mariadb service:


[root@srv1 ~]# systemctl enable --now mariadb
[root@srv1 ~]# systemctl status mariadb

The Datafiles of mariadb is located at:


[root@srv1 ~]# ls /var/lib/mysql/mysql/

.frm --> metadata files


.MYD --> the database files
.MYI --> index

The configuration file for mariadb:


If we need to connect from outside the network we must enable mariadb in firewall
and check the port number:

[root@srv1 ~]# firewall-cmd --add-service=mysql–permanent

[root@srv1 ~]# firewall-cmd–reload

To connect to the database securely we must use the installation script, to avoid
man in the middle attack.
Note: In mysql or mariadb, the user accounts is database account not files system
account, so maybe we have database account in mariadb that is not in the current
file system.

To login to the database we use the following:


To show the Available databases:

Note: Every command written in mysql or Mariadb must ended with semi-column
(;), it you need to have help we use\h or to clear the input we use \c.

To enter inside one of the databases:

Note: to differentiate between the command and any attribute or database or table
or value, it is recommended to write the command in uppercase.

To show the tables inside the database:


To query the information inside the database:
MariaDB [mysql]> SELECT * FROM user \G;

Here is the information inside the table user, this information is shown in rows. If
we want to show only three fields from the user table.

If we want the attributes and describtion for a record so we use:


To show a specific field (Host) from user table:

Where * means I want to view all fields


Table: user
I want to get the Value of srv1.lab.local from column Host, note that the values
written between single quotes.

To create database:

We have to create users with passwords to access the students’ database.

User:tarek
Machine: any
Password:iti@123
Note: by default the users that is created by default the do not have any privileges
to do anything.

To add privileges:

Means allow tarek to login form either localhost or the FQDN Name to have
access on the database students on all tables.

Username: tarek
Machine name to connect to database: server.lab.local
Password for tarek: iti@123
NOTE: tarek is DBMS user account not Linux OS Account
[(none)]: means it is not connected to any database now

Where:
All means: SELECT, CREATE, INSERT, ALTER , DROP, UPDATE.
*.*: the database.tables
To: user 'tarek'@'server.lab.local'

To apply the changes for users we must make refresh for the databases
Try to login with user tarek:

To drop user account:

To Create Table:

Table: names
Fields (user_id, username, password, email)
Type: VARCHAR (),CHAR (character type and length), INT (integer type and
length), NOT NULL, PRIMARY KEY, AUTO INCREMENT, TIME STAMP,
STRING.

To Insert data inside the names table inside students database:

Table: names
Fields: user_id, username, password, email
Values:1, tarekelbaz, iti@123, [email protected]
Note: values must written between single quotes.

To make delete operation:

Delete FROM
Tables= names
Where email field is '[email protected]'
NOTE: when we use delete option without using where statement it will delete
the table.

To update record in the table.

UPDATE
Table = names
SET the field password (from 'iti2123' to be '123')
Where the username field = 'adel'

Creating Database Backup & Restore operation:

Where students is the database that needed to be backed

Here it will create all databases backup

To restore:

----------------------------------------------------------------------------------------------------
--------------------
Enable and install the following repos:
epel& repo.mysql.com
To enable web access for MYSQL:
Change the root account and root password
To enable the web server:

Enable the ip address and restart the following httpd&mariadb


Note: do not forget to enable the port number of Mariadb and http on the firewall.

Note:We have to restart httpd service

You might also like