Month: November 2007

how to reset MySQL root user password with different methods

how to reset MySQL root user password with different methods

 when  you loss  mysql  root  pasword. then  stop  mysql  server.. then  follow  below  steps.

 * Method -1

1]  Start  MySQL without  loading  grant access…

root@indiangnu:~# mysqld –skip-grant-tables &
[1] 10197
root@indiangnu:~# 071129  9:41:39  InnoDB: Started; log sequence number 0 43655
071129  9:41:39 [Note] mysqld: ready for connections.
Version: ‘5.0.22-Debian_0ubuntu6.06.3-log’  socket: ‘/var/run/mysqld/mysqld.sock’  port: 3306  Debian Etch distribution
2] Start MySQL client

root@indiangnu:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.22-Debian_0ubuntu6.06.3-log

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> use  mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed

mysql> UPDATE user SET Password=PASSWORD(‘password’) WHERE User=’root’;
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye
root@indiangnu:~#

* Then  kill current  MySQL process service… and  start  normal  MySQL  daemon

* Method -2  

1]  Start  MySQL  in safe mode without  loading  grant access…

root@indiangnu:~# mysqld_safe –skip-grant-tables &
[1] 10216
root@indiangnu:~# Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[10277]: started

2] Start MySQL client
root@indiangnu:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.22-Debian_0ubuntu6.06.3-log

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> UPDATE user SET Password=PASSWORD(‘password’) WHERE User=’root’;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2  Changed: 0  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
root@indiangnu:~#

Thank  you,

Arun Bagul

MySQL full DB dump -shell script

MySQL full DB dump -shell script

#!/bin/bash
#Shell script to backup MySQL database
#To set permission to user which can take  backup of all the DB in
#MySQL server. plzsee query below
#mysql> grant SELECT, LOCK TABLES  on  *.*  to
#’backup_user’@’localhost’ identified  by  ‘pwd_of_user’;
#
#(c)arunbagul@indiangnu.org
###############################################################
#DB details
user_name=”user”
user_pwd=”password”
myhost=”localhost”

# Linux bin paths, change this if it can’t be autodetected via which command
mysql_cmd=”$(which mysql)”
dump_cmd=”$(which mysqldump)”
CHOWN=”$(which chown)”
CHMOD=”$(which chmod)”
zip_cmd=”$(which gzip)”

# Backup Dest directory, change this if you have someother location
dest_dir=”/var/mysql-backup/

# Get hostname
host_name=”$(hostname)”

# Get data in dd-mm-yyyy format
NOW=”$(date +”%d-%m-%Y”)”

# File to store current backup file
FILE=””
# Store list of databases
DB_list=””

# DO NOT BACKUP these databases
Ignore_db=”test”

[ ! -d $MBD ] && mkdir -p $MBD || :

# Only root can access it!
$CHOWN 0.0 -R $dest_dir
$CHMOD 0600 $dest_dir

# Get all database list first
DB_list=”$($mysql_cmd -u$user_name -h $myhost -p$user_pwd   -Bse ‘show
databases’)”

#send db list to file and clear previous  content
echo “” > $mail_file
echo “” > $database_file

for db in $DB_list
do
skipdb=-1
#send DB list to file
echo $db >> $database_file
echo $db
if [ “$Ignore_db” != “” ];
then
for i in $Ignore_db
do
[ “$db” == “$i” ] && skipdb=1 || :
done
fi

if [ “$skipdb” == “-1″ ] ; then
FILE=”$dest_dir/$db.$host_name.$NOW.gz”
my_file=”$dest_dir/${db}_${host_name}.sql”
# do all inone job in pipe,
# connect to mysql using mysqldump for select mysql database
# and pipe it out to gz file in backup dir 🙂
# $dump_cmd -u $user_name -h $myhost -p$user_pwd $db | $zip_cmd -9 > $FILE
# DB dump start here
########################################
$dump_cmd -u $user_name -h $myhost -p$user_pwd $db > $my_file
if [ $? -eq 0 ]; then
echo $db >> $mail_file
fi
########################################
fi
done

#end

python script for sending mail.

python script for sending mail.

#!/usr/bin/python
#This  scritp  will send mail  in both HTML and Text format
#@arunbagul@indiangu.org
#@GPL
import smtplib
import os
import sys
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders

#guess = sys.argv[1]
fromaddr = “arunbagul@indiangnu.org”
toaddrs = “toaddress@indiangnu.org”

#———————————–
file_name = “/home/arunbagul/mail-body.txt”
file = open(file_name)
msg = file.read();
#———————————-
#msg = MIMEMultipart()
#msg[‘From’] = fromaddr
#msg[‘To’] = COMMASPACE.join(toaddrs)
#msg[‘To’] = toaddrs
#msg[‘Date’] = formatdate(localtime=True)
#msg[‘Subject’] = “This is my Sub”

server = smtplib.SMTP(‘192.168.1.5’)
#server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, msg)
#server.sendmail(fromaddr, toaddrs, msg.as_string())
server.quit()

Load Balancing – shell script

Load Balancing – shell script

#!/bin/bash
echo “——————————————-”
echo “”
echo -e “Wel come to Load Balancing………….”
echo -e “@arunbagul@indiangnu.org”
echo “”
echo “——————————————-”
#################################
#**root@proxy# cat  /etc/iproute2/rt_tables
#
# reserved values
#
#**255     local
#**254     main
#**253     default
#**0       unspec
#Entry manually added
#please  add this two line each internet connections
#for example two connections
#**251    sify3
#**252    tata
#################################

#specify Details
#Local LAN
LAN_IF=eth0
LAN_IP=192.168.1.68
LAN_NWK=192.168.1.0/24

#INET1 (internet connection )
INET1_IF=eth1
INET1_IP=10.10.172.230
INET1_NWK=10.10.172.0/24
INET1_GW=10.10.172.X

#INET2 (internet connection )
INET2_IF=eth2
INET2_IP=208.259.169.X
INET2_NWK=208.259.169.X/30
INET2_GW=208.259.169.X

#################################
case “$1” in

start)
#Start Load Balancing……..
echo -e “Starting Load Balancing……..”
##################################################################
#step(1)
#Flush out table tata  & sify3 if any routing is their.
/sbin/ip route flush table tata
/sbin/ip route flush table sify3
#################################
echo -e “Creating Kernel routing table::- tata(251)”
# 202.189.249.204/30 is IP n/w of ISP1 with
#gateway is 202.189.249.205 & IP assign
#to eth3  is 202.189.249.206 which is source(src)
/sbin/ip route add $INET2_NWK dev $INET2_IF src $INET2_IP proto kernel table tata
#Add entry for internel n/w
/sbin/ip route add $LAN_NWK dev $LAN_IF proto kernel src $LAN_IP table tata
#Now add default gateway to ISP-I in table tata
/sbin/ip route add default via $INET2_GW table tata
##################################################################
#step(2)
echo -e “Creating Kernel routing table::- sify3(253)”
# 10.10.127.0/24 is IP n/w of ISP2 with
# gateway is 10.10.127.1 & IP assign
#to eth1  is 10.10.127.222 which is source(src)
/sbin/ip route add $INET1_NWK  dev $INET1_IF  src $INET1_IP proto kernel table sify3
#Add entry for internel n/w
/sbin/ip route add $LAN_NWK dev $LAN_IF proto kernel src $LAN_IP table sify3
#Now add default gateway to ISP-II in table sify3
/sbin/ip route add default  via $INET1_GW  table sify3
##################################################################
#step(3)
#set up the routing rules.
#These actually choose what routing table to route with.
/sbin/ip rule  add from $INET2_IP table tata
/sbin/ip rule  add from $INET1_IP table sify3
##################################################################
#step(4)
#Delete default route path form kernel ‘main’ routing table.
/sbin/route del default
if [ $(echo $?) = 0 ] ; then
echo -e “Default gateway removed from ‘main’ table”
fi
/sbin/route del default
echo “Done………”
##################################################################
#step(5)
#now set up the default route to be a multipath route.
#In the default kernel this will balance routes over the two providers.
#/sbin/ip route add default equalize nexthop via $INET1_IP $dev $INET1_IF weight 1 nexthop via $INET2_IP dev $INET2_IF weight 1
/sbin/ip route add default  nexthop  via $INET1_IP dev $INET1_IF weight 1 nexthop via $INET2_IP dev $INET2_IF  weight 1
echo -e ” Thank you….”
##################################################################
;;
stop)
#Stoping Load Balancing….
echo -e “Stoping Load Balancing….”
#Seperating routing decision…
/sbin/ip rule del from $INET1_IP table tata
/sbin/ip rule del from $INET1_IP  table sify3
#Flush out table tata,sify3 and main if any routing is their.
/sbin/ip route flush table tata
/sbin/ip route flush table sify3
/sbin/ip route flush table main
#update kernel ‘main table’————–
#add entry for ‘tata’ connection
/sbin/ip route add $INET2_NWK  dev $INET2_IF  src $INET2_IP  proto kernel  scope link  table main
#add entry for ‘sify’ connection
/sbin/ip route add $INET1_NWK  dev eth1  src $INET1_IP proto kernel  scope link  table main
#Add entry for internel n/w
/sbin/ip route add $LAN_NWK  dev $LAN_IF proto kernel scope link src 192.168.0.3 table main
#Now add default gateway to ISP-I in table main
/sbin/ip route add default via $INET1_GW table main
;;
status)
#Checkng Load Balancing status….
echo -e “Checking Load Bal status…….”
#Check load balancing is successful or not————-
/sbin/ip route show | grep “nexthop” > /dev/null
if [ $(echo $?) = 0 ] ; then
echo -e “Load Balancing is SUCCESSSFUL”
else
echo -e  “Load Balancing FAILED”
echo -e “Load-balancing:: Please try again…”
fi
;;
table)
#Kernel routing table
#################################
echo -e “Kernel routing table ‘tata’ is…..”
/sbin/ip route show table tata
echo -e “Kernel routing table ‘sify3’ is…..”
/sbin/ip route show table sify3
#Now finally check kernel routing with default route as multiple route
echo -e “~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~”
echo -e “Kernel ‘main’ routing table is…(plz check here)”
/sbin/ip route show table  main
echo -e “………..”
/sbin/route -n
echo -e “~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~”
echo -e “!!please run this cmd when ever you will restart n/w service or PC.”
echo -e ” And make sure that both connection are running”
;;

*)
echo “Usage:/sbin/load-balancing {start|stop|status|table}”
exit 1
;;
esac
#################################
#exit 0
#END

Samba as PDC

Samba as PDC

1] Samba Server

We are using samba as PDC so that windows machine will be authenticated using same mysql DB.
But samba as mysql is not supported for practical use. In our case we are using samba with
smbpasswd file and this file ia updated by using samba-Daemon. This daemon is written in python.

* Samba Server can be used as PDC with

1) Roaming profiles and
2) Local profiles
  • We are using samba as PDC with local profile so that we don’t need to create profile and netlogon share in samba.

2] Samba Configuration File

[global]

#Change this to the workgroup/NT-domain name your Samba server will part of

#############################

workgroup = IndianGNU.org

netbios name = fileserver

os level = 65

prefered master = yes

domain master = yes
local master = yes
domain logons = yes
 ;Domain administrators
 admin users = arun.bagul,nishit

#############################

  ## Networking
   hosts allow = 192.168.0.0/24 127.0.0.1
 ## Authentication #"security = user" is always a good idea.
This will require a Unix account
security = user
;should be true
encrypt passwords = true
 ##If you are using encrypted passwords, Samba will need to know what

#password database type you are using.
#*** passdb backend = tdbsam  ;commented by arun
#############################
#This is the most imp entry for smbpasswd database
passdb backend =  smbpasswd:/etc/samba/smbpasswdobey

pam restrictions = yes

#############################
guest account = nobody

invalid users = root
##Domains
;For roaminf  profiles following line should be uncommented

;logon path = \\%N\profiles\%U
;For Local Profile "logon path" should be nothing

logon path =logon drive = H:
logon home = \\%N\%U
#############################
## Printing
#For samba with CUPS server

loadprinters = yes

printing = cups

printcap name = cups

browseable = yes

printer admin = arun.bagul
#############################
## Misc
##socket options = TCP_NODELAY ; commented by arun

socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

######
#############################
##Share defineded here
;Please don't define this share
;[profiles]
#############################
[netlogon]

comment = IndianGNU.org Network Logon Service

path = /etc/samba/netlogon

guest ok = yes

public = no

writable = no

;read only = yes

browseable = no

valid users = %U
#############################
#NOTE- Above [netlogon] share is also not needed for samba with Local profiles
#############################
##Samba share per team
[Team1]

comment = Team1 Share

path = /winbackup/team1
browseable = yes

writable = yesvalid users = @team1
;create mask = 0600

;directory

mask = 0700;

guest ok = yes
#########################

[Team2]

comment = Team2 Share

path = /winbackup/team2

read only = no

browseable = yes

writable = yes

valid users = @team2
;guest ok = yes
#########################

3] Machine Account creation

To use samba for windows domain controller, We need to create machine account for each windows machine.

say Netbios name of windows machine is “systemws” then cmd for creating machine account is……..

root@fileserver:/etc# useradd -d /dev/null -g 65534 -s /bin/false systemws$
root@fileserver:/etc# useradd -d /dev/null -g 65534 -s /bin/false qawd1$
root@fileserver:/etc# useradd -d /dev/null -g 65534 -s /bin/false qawd2$
root@fileserver:/etc# useradd -d /dev/null -g 65534 -s /bin/false utkarshws$
  • How to add machine account in smpasswd file
root@fileserver:/etc# smbpasswd -m -a systemws
Added user systemws$.
root@fileserver:/etc# smbpasswd -m -a qawd1
Added user phplws$.
root@fileserver:/etc# smbpasswd -m -a qawd2

Added user qawd1$.

root@fileserver:/etc#

4] User Account creation

To create Normal user account for domain logon

root@fileserver:/etc# smbpasswd -a arun.bagul
 New SMB password:
 Retype new SMB password:
root@fileserver:/etc#

Thank you,

Arun Bagul

Load Balancing for sharing multiple internet connections

Load Balancing for sharing multiple internet connections

Overview

We have three Internet connection from three different ISP.

Due to hardware limitation we have connected two ISP line connected to one PC.
Details regarding to Interface is-
etho -192.168.0.X
eth1- A.B.C.D

ppp0- W.X.Y.Z

Why Load Balancing ?

The main purpose of load balancing is to share multiple Internet connection from different service provider for maximum utilization of bandwidth. We try to achieve this goal by two method

A) Load Balancing by using EQL interface-

EQL is serial line load balancer which is kernel module. by which we can enslave or tie multiple serial line from different or same provider. But the condition is that this line should be connected through modem. Which is not suitable for us.

B) Load Balancing by IP tables and Routing-

There are many places where a Linux based router/masquerading device can assist in managing multiple Internet connections. We’ll outline here some of the more common setups involving multiple Internet connections and how to manage them with iptables and routing. One of the first distinctions you can make when planning how to use multiple Internet connections is what inbound services you expect to host and how you want to split traffic over the multiple links.

Step by step implementation

When we are using single connection from one ISP in such case our default route will me in ‘main’ routing table of kernel. Now in our case we have connected two connection to proxy server out of that one line is from ‘pacenet’ and other is from ‘sify’. As we have not implemented load balancing the default router in ‘main’ table of kernel will be either fro sify or pacenet.

[1] How it works

Lets us check our ‘main’ routing table ….

magnet@proxy:~$ ip route show table main
25.X.X.X dev ppp0 proto kernel scope link src W.X.Y.Z
192.168.0.X/24 dev eth0 proto kernel scope link src 192.168.0.X
10.X.X.X/24 dev eth1 proto kernel scope link src A.B.C.D
default dev ppp0 scope link
magnet@proxy:~$

root@proxy:~# ip route show table main
25.X.X.X dev ppp0 proto kernel scope link src W.X.Y.Z
192.168.0.X/24 dev eth0 proto kernel scope link src 192.168.0.X
10.X.X.X/24 dev eth1 proto kernel scope link src A.B.C.D
default via 10.X.X.X dev eth1
root@proxy:~#

To use both the line effectively we need to create to two new routing table. So that we can provide default gateway in each routing table separately.

Step [1]

First step in load balancing is to create separate routing table for each connection. Lets create table.

root@proxy:~# tail /etc/iproute2/rt_tables
253 sify3
252 sify192
251 pacenet
root@proxy:~#

Whenever we want to create new routing table we need to add entries in above file.

step [2]

Now we will add routing details in this table

root@proxy:~# ip route add 25.X.X.X dev ppp0 src W.X.Y.Z proto kernel scope link table pacenet
root@proxy:~# ip route add default via 25.X.X.X table pacenet
root@proxy:~# ip route show table pacenet
25.X.X.X dev ppp0 proto kernel scope link src W.X.Y.Z
default via 25.X.X.X dev ppp0
root@proxy:~#

As shown above we have created separate routing table ‘pacenet’ for pacenet connection. With default gateway 25.X.X.X and interface ppp0.
Similarly we have created separate routing table ‘sify3’ for sify connection. with defalut gateway 10.X.X.X and interface eth1.

root@proxy:~# ip route add 10.X.X.X/24 dev eth1 src A.B.C.D proto kernel scope link table sify3
root@proxy:~# ip route add default via 10.X.X.X table sify3

root@proxy:~# ip route show table sify3
10.X.X.X/24 dev eth1 proto kernel scope link src A.B.C.D
default via 10.X.X.X dev eth1
root@proxy:~#

step [3]

One more thing we left here is that we have to add entries for local network in both table. This is basic setup for separating routing decision for both provider.

root@proxy:~# ip route add 192.168.0.X/24 dev eth0 proto kernel scope link src 192.168.0.X table sify3
root@proxy:~# ip route add 192.168.0.X/24 dev eth0 proto kernel scope link src 192.168.0.X table pacenet

Finally we will check entries in each routing table

root@proxy:~# ip route show table sify3
192.168.0.X/24 dev eth0 proto kernel scope link src 192.168.0.X
10.X.X.X/24 dev eth1 proto kernel scope link src A.B.C.D
default via 10.X.X.X dev eth1

root@proxy:~# ip route show table pacenet
25.X.X.X dev ppp0 proto kernel scope link src W.X.Y.Z
192.168.0.X/24 dev eth0 proto kernel scope link src 192.168.0.X
default via 25.X.X.X dev ppp0
root@proxy:~#

step [4]

Next, we will set up the routing rules. These actually choose what routing table to route with. You want to make sure that you route out a given interface if you already have the corresponding source address:

root@proxy:~# ip rule add from W.X.Y.Z table pacenet
root@proxy:~# ip rule add from A.B.C.D table sify3

Here W.X.Y.Z is the static IP assign to ppp0 interface. The first rule tells to kernel that use table ‘pacenet’ to route all the pkts going out of interface ppp0 similarly for sify connection.

Step [5]  Now delete default route in ‘main’ table.

root@proxy:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
25.X.X.X 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.0.X 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.X.X.X 0.0.0.0 255.255.255.0 U 0 0 0 eth1
0.0.0.0 10.X.X.1 0.0.0.0 UG 0 0 0 eth1
root@proxy:~# route del default
root@proxy:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
25.1.1.2 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.10.127.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
root@proxy:~# ip route show
25.1.1.2 dev ppp0 proto kernel scope link src 203.115.69.16
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.3
10.10.127.0/24 dev eth1 proto kernel scope link src 10.10.127.222

Step [6]

Now the question is how to balance traffic going out over the two providers. This is actually not hard if you already have set up split access as above. Instead of choosing one of the two providers as your default route,We will set up the default route to be a multipath route. In the default kernel this will balance routes over the two providers. It is done as follows (once more building on the example in the section on split-access):

root@proxy:~# ip route add default nexthop via 10.X.X.1 dev eth1 weight 1 nexthop via W.X.Y.Z dev ppp0 weight 1

root@proxy:~# ip route show
25.X.X.X dev ppp0 proto kernel scope link src W.X.Y.Z
192.168.0.X/24 dev eth0 proto kernel scope link src 192.168.0.X
10.X.X.X/24 dev eth1 proto kernel scope link src A.B.C.D
default
nexthop via A.B.C.D dev eth1 weight 1
nexthop via W.X.Y.Z dev ppp0 weight 1
root@proxy:~#

This will balance the routes over both providers. The weight parameters can be tweaked to favor one provider over the other.
Note that balancing will not be perfect, as it is route based, and routes are cached. This means that routes to often-used sites will always be over the same provider.
Thank you

Arun Bagul

Reference URL:–
http://linux-ip.net/html/index.html
http://linux-ip.net/html/ch-advanced-routing.html

http://lartc.org/howto/lartc.rpdb.html
http://lartc.org/howto/lartc.rpdb.multiple-links.html

http://www.shorewall.net/

IndianGNU.org – my first anniversary!!

IndianGNU.org – my first anniversary!!

I am glad to inform you all that today is my first anniversary!!. We have successfully completed one year of social contribution in open source and free software movement. I am very much sure that our existence and contribution is recognized and encouraged by many open source and free software contributors (gurus). It was simply impossible without your support, contribution and hard work. In past one year the number of contributors are grown from 1 to 25!!. This is one of the achievement we have added in our treasury. I am very thankful to all contributors for there contribution, dedication and keen interest.

We started with blogging, sharing our knowledge, ideas and even problem!! also. This is helped us to learn new technologies, problem solving skills and many more things.

What next?
Now it time to think about what Next? What we want to achieve in next one or two years? how we will grow? what we should? and many more things.

For next one year we will continue with blogging and sharing our knowledge, at same time we have to encourage more people to join our community and grow day by day!! I am sure that you are agree to me and wiling to support to archive this goal.

Our focus will be on openLSM– open source or free software project. We have to start actual coding and release beta version of openLSM by end of this year. I am expecting more from all of you. I hope that you will put best effort to achieve this target!!!.

Cheers,
IndianGNU.org

How to delete MySQL command line history

How to delete MySQL command line history

Introduction – On Unix or Linux system, the MySQL client writes a record of executed statements to a history file. By default, the history file is named .mysql_history and is created in your home directory. To specify a different file, set the value of the MYSQL_HISTFILE environment variable.

root@arunbagul:~# ls -l /root/.mysql_history
-rw——- 1 root root 71 2008-03-18 17:25 /root/.mysql_history
root@arunbagul:~#

root@arunbagul:~# cat /root/.mysql_history
show databases;
select * from databases;
show status;
show variables;
root@arunbagul:~#

If you do not want to maintain a history file, first remove .mysql_history if it exists, and then use either of the following techniques:

  • Set the MYSQL_HISTFILE variable to /dev/null. To cause this setting to take effect each time you log in, put the setting in one of your shell’s startup files.
  • Create .mysql_history as a symbolic link to /dev/null
  • ln -s /dev/null $HOME/.mysql_history

How to set Environment variable –

root@arunbagul:~# export MYSQL_HISTFILE=/dev/null

root@arunbagul:~#

** Please add about command in .bashrc file in your home directory so that this variable will be set to /dev/null value every time you lonin ..

root@arunbagul:~# cat /root/.bashrc
root@arunbagul:~#
Check the environment variable –

root@arunbagul:~# echo $MYSQL_HISTFILE
/dev/null
root@arunbagul:~#

NOTE- It’s not secure to save all executed mysql command to $HOME/.mysql_history file!!

Regards,

Arun Bagul