Saturday, September 5, 2015

Creating MYSQL User


We did all of the editing in MySQL as the root user, with full access to all of the databases. However, in the cases where more restrictions may be required, there are ways to create users with custom permissions.


1. Creating a new user:
CREATE USER '<password>'@'%' IDENTIFIED BY '<password>';

2.  After creating user, now it's the time to provide grants.
GRANT SELECT ON db_name.* to '<username>'@'%';
 #Above command will provide read only permission to the user for specified database

3. Reload all the changes made.
FLUSH PRIVILEGES;


Sample grant example:

1.  Providing full permission to a user on all databases.
GRANT ALL PRIVILEGES on *.* to  '<username>'@'%';


Tuesday, September 1, 2015

pg_dump issue while taking postgresql database dump

You might have face below issue or exception when you are taking dump of postgresql server.

pg_dump: server version: 9.4.4; pg_dump version: 9.2.13
pg_dump: aborting because of server version mismatch



In this case follow the below steps to resolve the issue.

Step 1: Install the postgresql new version.
yum install postgresql94

#This will add missing packages.


Step 2: Execute the pg_dump command with new version.
/usr/bin/pg_dump94 -h <hostname> -U <username> -W<db-name>   > file.sql
prompt for password