Physical location of datafiles in PostgreSQL
Data Directory
Basic Operations on MySQL Users
In this article we are going to discuss about
different operations on mysql user like lock, unlock, grant, revoke etc.
- Lock-unlock
- Expire-unexpired
- Check privileges
- Revoke privileges
- Change password
- Rename user (single user, multiple user)
- Drop user
select
user,host,authentication_string,password_expired,account_locked from user where
user like 'test%';
We can all accounts are unlocked and password not expired.
We will perform operations one by one
LOCK and UNLOCK
Let’s lock and unlock test@%
Locking the account
alter user ‘test’@’%’ account lock;
Checking the status
select user,host,authentication_string,password_expired,account_locked
from user where user like 'test%';
Unlocking it again
alter user ‘test’@’%’ account unlock;
This will affect only test@% not test@localhost, both are different users.
EXPIRE
Let’s expire password for 'test'@'localhost' and
revert it
alter user ‘test’@’localhost’ password expire;
Verification
select
user,host,authentication_string,password_expired,account_locked from user where
user like 'test%';
Password reset using values
alter user ‘test’@’localhost’ identified with
‘mysq_native_password’
as ‘*5BA7FD292EB16719F76792ECAF589CE4B62CCC94’;
Verifying status again
select
user,host,authentication_string,password_expired,account_locked from user where
user like 'test%';
CHECK PRIVILEGES
show grants for ‘test2’@’locahost’;
REVOKE PRIVILEGES
In below example grants of test2@localhost has been
revoked
show grants for ‘test2’@’localhost’;
revoke SELECT, INSERT, DELETE CREATE, DROP, RELOAD,
ALETER ON *.* from ‘test2’@’localhost’;
flush privileges;
show grants for ‘test2’@’localhost’;
CHANGING PASSWORD
In below example password of test3@% has been
altered.
select user, host, authentication_string,
password_expired, account_locked from user where user like 'test%';
alter user ‘test3’@’%’ identified by ‘Hudrt#12’;
select user, host, authentication_string,
password_expired, account_locked from user where user like 'test%';
RENAME USER
show grants for ‘test1’@’localhost’;
Single user
In mysql we can rename the user without dropping it but modification needs to be carried wherever it is not getting used, grants will not get altered
Single user- in below example ‘test1’@’localhost’
user has been renamed with ‘xyz1’@’localhost’
rename user ‘test1’@’localhost’ to
‘xyz1’@’localhost’;
show grants for ‘xyz1’@’localhost’;
select user, host, authentication_string,
password_expired, account_locked from user where user like xyz1%';
Multiple user
select user, host, authentication_string,
password_expired, account_locked from user where user like 'test%';
rename user ‘test’@’localhost’ to ‘abc’@’%’,
‘test’@’%’ to ‘abc’@’localhost’;
select user, host, authentication_string,
password_expired, account_locked from user where user like 'test%';
select user, host, authentication_string,
password_expired, account_locked from user where user like 'abc%';
DROP USER
In below example we are dropped abc user
select user,host from user where user=’abc’;
drop user ‘abc’@’localhost’;
select user,host from user where user=’abc’;
drop user ‘abc’@’%’;
select user,host from user where user=’abc’;
Oracle : STATISTICS_LEVEL parameter
This particular parameter has below three possible settings
- BASIC
- TYPICAL
- ALL
Transferring file from one server to another server [FTP, SFTP, SCP etc]
Atikh Shaikh
MongoDB, mysql, oracle, Oracle 12c, PostgreSQL
No comments
- ftp
- sftp
- scp
- windows software (Filehippo, WinScp , FileZilla etc)
1. FTP transfer
User :
Password :
ftp> bin -- to transfer in binary format
ftp> cd
ftp> put/get
ftp>bye
2. SFTP transfer
As name suggest SFTP is secure file transfer protocol, it uses full security and authentication functionality of SSH. SFTP is new utility compared to FTP and recommended to use instead of FTPThis utility can be used using below commands
$sftp
password : ***
sftp>cd
sftp> put/get
sftp> bye
3.SCP
SCP is used for securely copying files from one server system to another server system.Below is syntax for the same
scp [OPTION] [user@]src_server:] file1 [user@]target_server:]file2
where
[user@]src_server:] file1 -- source file
[user@]target_server:]file2 -- destination file
for example
scp text_file.txt
4. Windows software
There are number of freely available software on internet, choose your favourite one and transfer files using simple GUIBelow are few I came across
- FileZilla
- Filehippo
- WinScp
- FireFTP
MongoDB : Capped Collections
- In comparison to the normal collection, capped collections are created in advance and are fixed in size
- Normal collections are created dynamically and automatically grow in size to fit extra data
- These capped collections are designed to consume less space and are rotating that means once allocated space is full, it will start writing from older documents again.
- Below operations are not allowed on a capped collection
- Documents can not be removed
- Updates that make documents to grow in size are not allowed
capped collection name : my_cap_col1
fixed size : 100000 byes
for example
Once capped collections are created, it can not be modified, it must be dropped and recreated with desired parameters
Converting normal collection to capped collection
There is no way to convert capped collection to normal collection
ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES
for example
PROCESS privileges is a global privilege.
we will try to grant it to user tech_user on author database
Here we see it failed with error 1221 (HY000).
In order to resolve this error, we need to reconsider this grant statement and its usage.
we must know global privileges can not be granted to the individual database, instead, it should be on all databases. i.e. use of *.* instead of an author.*
- FILE
- PROCESS
- REPLICATION CLIENT
- REPLICATION SLAVE
- SUPER
MySQL: pid-file (process id file)
- The server writes its process id into pid file when mysql services are started and removes file when stopped.
- The pid file is the means by which a server allows itself to be found by other processes.
default location of pid file is data directory or it can be specified by specific variable
pid-file=file_name
generally pid file is given as hostname.pid
Content
The pid file content the process identification number of mysqld process, you can see content by using below command
cat
and also see the process id of mysql daemon process using
ps -ef|grep mysqld
you can see content of pid file and this process id identified using ps -ef command are same.
Aggregation Function in MySQL
Aggregation function s are generally used with SELECT statements containing GROUP BY clauses, however these may be used without group by clauses as well.
Below table describes aggregation functions available in MySQL (including MySQL 8.0 version)
Name
|
Description
|
AVG()
|
Returns average value of argument
|
BIT_AND()
|
Return bitwise AND
|
BIT_OR()
|
Return bitwise OR
|
BIT_XOR()
|
Return bitwise XOR
|
COUNT()
|
Return a count of rows
|
COUNT(DISTINCT)
|
Return a count of number of different values
|
GROUP_CONCAT()
|
Returns concatenated string
|
JSON_ARRAYAGG()
|
Return result set as single array
|
JSON_OBJECTAGG()
|
Return result set as a single object
|
MAX()
|
Returns maximum value
|
MIN()
|
Returns minimum value
|
STD(), STDDEV(), STDDEV_POP()
|
Returns the population standard deviation
|
STDDEV_SAMP()
|
Returns the sample standard deviation
|
SUM()
|
Return the summation
|
VAR_POP()
|
Return population standard variance
|
VAR_SAMP()
|
Returns sample variance
|
VARIANCE()
|
Returns Population standard variance
|
In below section, we will discuss few of these with examples,
first we will create table agg_tut for use with few records in it.
CREATE TABLE agg_tut (
emp_id int NOT NULL,
emp_name varchar(255),
salary double,
itax double,
age int
);
insert into agg_tut values ('101','John','12500','0','25');
insert into agg_tut values ('102','Smith','52500','2500','45');
insert into agg_tut values ('103','Jinh','22500','2200','32');
insert into agg_tut values ('104','Mist','15500','1000','23');
insert into agg_tut values ('105','Suki','13000','1200','28');
insert into agg_tut values ('108','Rock','33000','1800','30');