To install maria db
[root@localhost
Desktop]# yum
install mariadb* -y
To start and enable mariadb
[root@localhost
Desktop]# systemctl
enable mariadb; systemctl start mariadb
[root@localhost
Desktop]# mysql_secure_installation
To check socket number of mariadb
[root@localhost
Desktop]# ss
–tulpn | grep mysql
To enable or disable mariadb in network (0=enable, 1=disable)
[root@localhost
Desktop]# vi
/etc/my.cnf
[mysqld]
Skip-networking=1
:wq
[root@localhost
Desktop]# systemctl start mariadb
To login on mariadb
[root@localhost
Desktop]# mysql
–u root –p redhat
To check databases in mariadb
Show databases;
To open database
Use mysql;
To create new database
Create database testing;
To check tables in database
Show tables;
To create table in database
Create table abc (user_name varchar(20),mod
integer(10));
or
Create table abc (
Name varchar(20),
Name1 integer(5),
Name2 integer(5),
Primary key (name2));
To insert values in table
Insert into abc values (‘kuldeep’,1234567890);
To check details of table
Describe abc
To check the values of table
Select * from abc
To check the specific values of specific column in table
Select * from abc where amp=’kuldeep'
To add or remove column in table
Alter
table abc add newcolumn varchar(5) notnull;
Alter table abc drop newcolumn;
To rename column
Alter table abc
change column_name new_name varchar(30);
To modify column
property
Alter table abc
modify column_name varchar(50);
To rename table name
Rename table
old_name to new_name;
To create user
Create user user1@localhost identified by ‘password’;
To delete user
Drop user user1@localhost;
To check users
Select host,user,password from user1;
To set privilege for the user
Grant select,update,insert,drop on
databasename.tablename to user1@hostname;
To remove privilege from the user
Revoke select,drop on databasename.tablename
form user1@hostname;
To give all privilege
Grant all on databasename.* to user1@hostname;
To change password for user
Set password for user1 = password(‘123456’);
To take backup of mariadb database
Mysqldump –u –p databasename >
backupfile.dump
To restore mariadb database
Mysql –u –p databasename < backupfile.dump
To bind the range through we can connect to database remotely
[root@localhost
Desktop]#vi
/etc/my.cnf
[mysql]
Bind-address=0.0.0.0
:wq
[root@localhost
Desktop]#mysql –u root –p
Grant all
privillages on database.* to ducat@’%’ identifiedby ‘1234’
To login on database server remotely
[root@localhost
Desktop]#mysql
–u u1 –p databasename –h 15.0.0.1