--> To install mariadb-server use following command
# yum install mariadb*
# systemctl start mariadb
# mysql
--> to show list of databases
MariaDB [(none)]> show databases;
--> to create a new database
MariaDB [(none)]> create database db;
--> here db is the name of database
--> to use the created database
MariaDB [(none)]> use db;
--> to create table inside the database(db)
MariaDB [(none)]> create table info(name char(20),password char(15));
--> here info is the name of table and name,password are attributes.
--> to insert values of attributes inside the table info
MariaDB [(none)]> insert into info(name,password)values('sarvesh','redhat');
MariaDB [(none)]> show tables;
MariaDB [(none)]> desc info;
--> to see the entire contents of the table
MariaDB [(none)]> select * from info;
--> to exit out of the database
MariaDB [(none)]> exit
--> to secure the database with password
[root@mariadb_server ~]# mysql_secure_installation
--> set the root password
--> Now login with the secure password
[root@mariadb_server ~]# mysql -u root -p
--> In case of forget password
[root@mariadb_server ~]# rm -rf /var/lib/mysql/*
---------------------------------------- #####---------------------------------------------
Some important commands to perform following inside the database
-->
To rename Table
# alter table
tablename rename
new_tablename ;
-->
To add new attribute to the existing table
# alter table
tablename add
attribute data_type(size) ;
-->
To remove attribute from the existing table
# alter table
tablename drop
attribute ;
-->
To change size of attribute or type of attribute
#alter table
tablename modify
attribute data_type(size) ;
-->
Fetching column without repetition of any data
# select distinct
column_name from
table_name ;
-->
To update the data in particular row
# update
table_name set
attribute='xyz' where
attribute='zyxa' ;
-->
To delete the particular row
# delete from
tablename where
attribute='X' ;
-->
To delete all rows in which data starting with 'X'
# delete from
tablename where
attribute like
'X%' ;
-->
To delete all tuples from the table
# truncate table
table_name ;
-->
To delete table schema along with its tuple
# drop table
table_name ;